Search⌘ K
AI Features

Solution: Number of Distinct Islands

Explore how to identify and count distinct islands in a binary grid using depth-first search. Understand the technique of normalizing island coordinates to represent shapes with hash maps, allowing effective comparison without rotation or flipping. This lesson clearly explains the algorithm, its implementation, and analyzes time and space complexity, equipping you to solve similar grid-based coding problems confidently.

Statement

Given an m x n binary matrix where 11 represents land and 00 represents water. An island is a group of connected 1s1s ...