← Back
00:00

Island Statistics

Snapchat interview questions · Medium · Coding round · 6 tests

The input is a binary grid of size m x n. A cell holding 1 is land and a cell holding 0 is water. Land cells that touch through a shared side (up, down, left or right) belong to the same island, and each island is as large as that connectivity allows.

In this practice variant, every island needs two measurements:

  1. Area: how many land cells make up the island.
  2. Perimeter: how many cell sides of the island face water or the edge of the grid.
Idle