Island Shape Perimeter
Given a two-dimensional integer matrix
of 1
s and 0
s where 0
represents empty cell and 1
represents a block that forms a shape, return the perimeter of the shape. There is guaranteed to be exactly one shape, and the shape has no holes in it.
Constraints
1 ≤ n, m ≤ 250
wheren
andm
are the number of rows and columns inmatrix
https://binarysearch.com/problems/Island-Shape-Perimeter
Examples
Example 1
Input
- matrix =
[[0,1,1],
[0,1,0]]
Output
- answer =
8
Leave a comment