Skip to content

Latest commit

 

History

History
11 lines (8 loc) · 536 Bytes

File metadata and controls

11 lines (8 loc) · 536 Bytes

Problem 14: Geometric Boundary (Island Perimeter)

Problem Statement

You are given row x col grid representing a map where grid[i][j] = 1 represents land and grid[i][j] = 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completely surrounded by water, and there is exactly one island. Determine the perimeter of the island.

Input Format

  • A 2D integer matrix grid.

Example

Input: grid = [[0, 1, 0, 0], [1, 1, 1, 0], [0, 1, 0, 0], [1, 1, 0, 0]]
Output: 16