DEV Community

Discussion on: Amazon's Interview Question: Count Island

Collapse
 
cathodion profile image
Dustin King

An island is surrounded by a group of adjacent cells that are all 1s.

Do you mean it's surrounded by adjacent 0's?

Collapse
 
cipak profile image
Ciprian Șerbu

a correct way to say it would be "an island is a group of adjacent cells that are all 1s, surrounded by 0s or array's margins"

Collapse
 
rattanakchea profile image
Rattanak Chea • Edited

This picture should clarify what it means. Each color group represents each island.
island

Collapse
 
cathodion profile image
Dustin King

Thanks, that's what I thought it meant, but wasn't sure.