Anonymous · shared experience20 Jun 2026 · 11 views
Walmart Global Tech: Count islands in a grid, then count only distinct island shapes
Problem. You get a 2D grid of land and water cells. First, count the islands, where an island is a group of land cells connected horizontally or vertically.
Follow-up twist. Change the solution to count only islands with different shapes. Two islands that match after translation count as one shape.
What the interviewer looked for.
- Grid traversal with DFS or BFS and finding connected components
- A way to encode each island's shape, for example by recording cell positions relative to the island's starting cell, so that equal shapes produce the same key
- Time and space complexity for both versions
The candidate rated the base question medium and said the follow-up pushed it to medium-hard. The post gave no grid sizes or sample input.
Comments 0
No comments yet. Ask the author something, or add what happened in your own round.