Search⌘ K

DIY: Number of Islands

Explore how to implement a function in Rust that counts the number of islands in a 2D grid of land and water. This lesson helps you develop problem-solving skills that map to common coding interview questions by analyzing and coding an efficient solution for connected components.

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 ...