Leetcode 694. Number of Distinct Islands
Given a binary grid, count how many distinct island shapes (connected components of 1s via 4-directional adjacency) appear, treating two islands as identical if they match up to translation (but not rotation/reflection). The key challenge is to normalize each island's shape (e.g., by relative coordinates or a traversal signature) so you can deduplicate shapes efficiently.
Asked at:
TikTok
Oracle
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Mid June, 2026
TikTok
Mid-level
You are given an m x n binary matrix grid. An island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water. An island is considered to be the same as another if and only if one island can be translated (and not rotated or reflected) to equal the other. Return the number of distinct islands. Example 1: Input: grid = [[1,1,0,0,0],[1,1,0,0,0],[0,0,0,1,1],[0,0,0,1,1]] Output: 1 Example 2: Input: grid = [[1,1,0,1,1],[1,0,0,0,0],[0,0,0,0,1],[1,1,0,1,1]] Output: 3
Mid November, 2025
Oracle
Senior
Nothing specific, exactly same question.
Hello Interview Premium
Your account is free and you can post anonymously if you choose.