Number of Islands
Medium · Graphs · about 20 minutes
Asked at Adobe, Amazon, DoorDash, Figma, Google, Microsoft, Palantir, Roblox, Asana, Notion, Canva, Epic Games, Riot Games, Electronic Arts, Unity, Anduril, Airtable, Toast, Autodesk.
Given a 2D grid of "1" (land) and "0" (water), count the number of islands. An island is a group of land cells connected horizontally or vertically.