Search⌘ K

DIY: Number of Islands

Explore how to count the number of islands in a 2D grid by implementing a function in C#. This lesson helps you understand grid traversal techniques and apply them to solve problems common in coding interviews at companies like Facebook.

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