Search⌘ K
AI Features

DIY: Number of Islands

Explore how to identify and count islands in a 2D grid composed of land and water elements. This lesson helps you implement an efficient solution for a graph traversal problem frequently asked in coding interviews, especially at Facebook. By learning this, you will improve your skills in mapping real-world scenarios to interview questions.

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