Find Perimeter of Island

Statement

Given a grid representing a map where: :

  • grid[i][j] = 1 represents land
  • grid[i][j] = 0 represents water

Each cell is a square with length = 1 and the grid is rectangular.

Find the perimeter of the island.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.