Search⌘ K
AI Features

DIY: Number of Islands

Explore how to solve the Number of Islands problem by identifying connected land areas in a 2D grid. Learn to implement a Swift function that counts islands formed by adjacent lands, preparing you for similar coding interview challenges focused on grid traversal and adjacency detection.

Problem statement

Given an m x n 2D grid map of 1's (land) and 0's (water), return the number of islands.

An island is surrounded by water and is ...