Island Perimeter
Easy
Arrays
Array
Matrix
Given a grid (1=land, 0=water), calculate the island perimeter.
Constraints
1 ≤ rows, cols ≤ 100
Examples
Example 1:
Input: 0 1 0 0
1 1 1 0
0 1 0 0
1 1 0 0
Output: 16
Example 2:
Input: 1
Output: 4
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console