#7 most askedVery commonMediumGrid graph
Number of Islands
New to Grid graph? Learn it from scratch firstGrids & Matrix Traversal โ
๐ข Asked in real interviews
No reports yet. Were you asked this? Be the first to say where.A grid of "1" (land) and "0" (water). Count the islands: groups of land connected up, down, left or right.
๐งช Practice
Write your solution, then press Run tests. Explain your approach out loud as you go.
def num_islands(grid):
pass
Output appears here. Press Run or Ctrl/โ + Enter.
Try it first. Struggling for a few minutes is how it sticks.