Amazon interview question

Graph question, island(1,0) one from leetcode