Amazon interview question

Islands problem that can be found on leetcode