MEDIUMasked at 8 companies

Number of Distinct Islands

A medium-tier problem at 62% community acceptance, tagged with Hash Table, Depth-First Search, Breadth-First Search. Reported in interviews at Splunk and 7 others.

Founder's read

Number of Distinct Islands hits your assessment and you panic because the grid looks like a standard DFS problem, but the trick isn't finding islands, it's proving they're different. You need to distinguish one island from another by shape, not just count them. Splunk, Snap, Aurora, Coupang, Anduril, ServiceNow, Oracle, and TikTok all ask this. With a 62% acceptance rate, candidates who know the pattern solve it fast. Those who don't waste 20 minutes trying to tweak a basic island counter. If you hit this live and blank on how to compare island shapes, StealthCoder surfaces the solution invisibly while you're screen sharing.

Companies asking
8
Difficulty
MEDIUM
Acceptance
62%

Companies that ask "Number of Distinct Islands"

If this hits your live OA

Number of Distinct Islands is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop.

Get StealthCoder
What this means

The trap is treating this like the classic number of islands problem. You count connected land cells and move on. But this asks for distinct shapes. Two islands with the same topology but different positions are the same island. The real move is to normalize each island's coordinates so that position doesn't matter, then store that normalized form in a hash set. DFS or BFS traces the boundary of each island and records relative paths (or deltas between cells). A hash function maps that path to a canonical string. If you've seen Union Find problems, you might reach for that, but hashing the island's signature is cleaner and faster. The gotcha: rotation and reflection count as distinct unless the problem says otherwise. Most candidates solve it with Hash Table and DFS together. This is where StealthCoder's value kicks in during a live OA, if the normalization pattern doesn't click, you get a working reference in seconds.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Number of Distinct Islands recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Number of Distinct Islands interview FAQ

Is this just a variant of the standard number of islands problem?+

No. Standard islands count connected components. Distinct islands must also distinguish shape. Two separate islands of the same shape should return the same count if they were the same component. You need to normalize each island's coordinates and hash its signature to filter duplicates. That's the core difference.

Why do Hash Table and DFS appear together in the topic list?+

DFS explores each island and records its cell positions. Hash Table stores a canonical representation of that island (usually a string of relative coordinates) to detect duplicates. You explore with DFS, then deduplicate with a hash set. Both are mandatory.

Do I need Union Find for this problem?+

Union Find is listed as a topic because it's a valid approach for grouping connected land cells. But most candidates use DFS or BFS instead. Union Find adds overhead without benefit here. Save it for problems where you need to merge disjoint sets dynamically.

What's the most common failure mode?+

Forgetting to normalize island coordinates. You find all islands correctly but store them as absolute positions. When you compare islands, identical shapes at different locations look different. Always translate each island so its top-left (or origin) cell is at 0,0 before hashing.

Is a 62% acceptance rate high for medium difficulty?+

Yes. Most medium problems range from 45 to 55 percent. Distinct islands is above average, which means the pattern is teachable and not hidden behind a severe edge case. Still, 38% of attempts fail, usually because candidates miss the normalization or hashing step.

Want the actual problem statement? View "Number of Distinct Islands" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.