Amazon interview question

Coding question about giving islands unique numbers.