Reported September 2026
Snapunion find

Most Stones Removed with Same Row or Column

Reported by candidates from Snap's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Snap OA. Under 2s to a working solution.
Founder's read

Snap reportedly put "Most Stones Removed with Same Row or Column" in an OA in September 2026, and the constraints are the first thing to read. Up to 1000 stones, coordinates up to 10000. Trying every removal order is a factorial mess, so brute force is dead on arrival. If your OA lands this week, the answer is a graph idea in disguise: connected components. Count them, subtract from the total, done. The code is short once you see it. If you blank on the framing mid-assessment, StealthCoder runs invisibly on your desktop and can hand you the approach while the proctor sees nothing.

The problem

There are stones at distinct integer coordinates on a two-dimensional plane. A stone may be removed if another remaining stone shares its row or its column.
Return the maximum number of stones that can be removed.

Function
removeStones(stones: int[][]) → int

Examples
Example 1
stones = [[0,0],[0,1],[1,0],[1,2],[2,1],[2,2]]
return = 5
All six stones form one connected component, so one must remain.
Example 2
stones = [[0,0],[0,2],[1,1],[2,0],[2,2]]
return = 3
Four corner stones are connected and the center stone is isolated, so two stones remain.

Constraints
1 <= stones.length <= 1000
0 <= stones[i][0], stones[i][1] <= 10000
All coordinates are distinct.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick: stones sharing a row or column are connected. In each connected component you can remove every stone but one, so the answer is stones.length minus the number of components. Build it with union-find or DFS. The clean version unions the row index with the column index, using something like x and y + 10001 so they don't collide, then counts distinct roots among the stones. That avoids the O(n^2) pairwise comparison, though with n at 1000 even that passes. The common pitfall is trying to simulate removals greedily, or forgetting that a lone stone is its own component and removes nothing. Another slip is letting row and column ids overlap in the same map. If you freeze during the live OA, StealthCoder is the hedge: it reads the problem on screen and gives you the union-find structure so you just type it out.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Most Stones Removed with Same Row or Column cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as most stones removed with same row or column. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Snap's OA.

Snap reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Most Stones Removed with Same Row or Column FAQ

What's the trick in Most Stones Removed with Same Row or Column?+

Think connected components. Any two stones sharing a row or column are linked. Within a component you can remove all but one stone. So the answer is total stones minus the number of components. Union-find or DFS both get you there quickly.

How hard is this one really?+

Medium on paper, easy once you spot the graph. The hard part is the reframing, not the code. If you've seen union-find on rows and columns before, it's about ten minutes. If not, the removal-order framing can eat your time.

Do I need to compare every pair of stones?+

No. With up to 1000 stones, pairwise checks would technically pass, but the cleaner approach unions each stone's row with its column. Offset column ids, for example y + 10001, so they never collide with row ids. Then count distinct roots.

Union-find or DFS, which should I pick?+

Either works. DFS needs adjacency grouped by row and column, or a pairwise scan. Union-find on row and column ids is shorter and has fewer bugs. Pick whichever you can write without hesitation under pressure.

How do I prepare for this in 48 hours?+

Write union-find from memory twice, with path compression. Then solve this problem and one number-of-islands style problem. Practice stating the formula out loud: stones minus components. That's the whole insight, and Snap's version matches the standard form.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Snap.

OA at Snap?
Invisible during screen share
Get it