463. Island Perimeter
Practice Island Perimeter for free on NudgeCode: Easy, Graph pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
The grid is a map where 1 is land and 0 is water. It contains exactly one island: all land cells are connected up, down, left or right, and there are no lakes (water fully enclosed by the island). Return the length of the island's coastline, counting each cell side as 1.
Example
grid = [[0,1,0,0],
[1,1,1,0],
[0,1,0,0],
[1,1,0,0]] -> 16
Constraints
- 1 <= m, n <= 100 (m rows, n columns)
- grid[i][j] is
0or1 - There is exactly one island and it has no lakes