Zoho interview question

Island problem from leetcode platform