Google interview question

Leet code problem with counting the islands.