avatar Bite 267. Measure the size of an island

In this algorithm Bite, the challenge is to measure the size of an island in the ocean, based on the 2D map that you have been provided.

In this map, 0 represents ocean and 1 land.

You can assume there is only one island on the map, you need to measure its size (or perimeter).

The matrix cells are connected horizontally and vertically, not diagonally.

Here is an example:
island size example

Good luck and keep calm and code in Python!

 

Login and get coding
go back Intermediate level
Bitecoin 3X

120 out of 122 users completed this Bite.
Will you be the 121st person to crack this Bite?
Resolution time: ~52 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 4.43 on a 1-10 difficulty scale.
» Up for a challenge? 💪

Focus on this Bite hiding sidebars, turn on Focus Mode.

Ask for Help