Reaching Points
Reported by candidates from Virtu Financial's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Values up to 10^9 mean you can't simulate moves forward, and you can't BFS this one either. That's the whole point of the Reaching Points question Virtu Financial candidates reported in September 2026. The input looks like a tree search, but it's really a number theory trick in disguise. Work backward from (tx, ty) and the path is forced, so there's exactly one parent at every step. If you blank on the reverse idea during the OA, StealthCoder is the safety net running invisibly on your screen. But the trick is short enough to learn tonight.
The problem
Start at the positive coordinate (sx, sy). In one move, replace it with either (sx + sy, sy) or (sx, sx + sy). Return whether some sequence of moves reaches (tx, ty). Function reachingPoints(sx: int, sy: int, tx: int, ty: int) → boolean Examples Example 1 sx = 1 sy = 1 tx = 3 ty = 5 return = true (1,1) can move to (1,2), then (3,2), then (3,5). Example 2 sx = 1 sy = 1 tx = 2 ty = 2 return = false Neither legal move can produce (2,2). Constraints 1 <= sx, sy, tx, ty <= 10^9
Reported by candidates. Source: FastPrep
Pattern and pitfall
Go backward. From (tx, ty), the previous point is unique. If tx > ty, the parent is (tx - ty, ty). If ty > tx, the parent is (tx, ty - tx). If they're equal, you're stuck, since no parent has positive coordinates. The pitfall is subtracting one step at a time. With values near 10^9 and a small other value, that's a billion iterations and a timeout. Use modulo instead. While tx > sx and ty > sy and tx != ty, reduce the larger one by the smaller with %. Then handle the endpoints. If tx == sx, check that (ty - sy) % sx == 0. If ty == sy, check that (tx - sx) % sy == 0. Otherwise return false. Watch the boundary where modulo overshoots below sx or sy, which is why the final checks matter. This is Euclid's algorithm in costume, so it runs in O(log) time. If the reverse insight escapes you live, StealthCoder can hand you the loop.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Reaching Points 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. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as reaching points. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Virtu Financial's OA.
Virtu Financial reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Reaching Points FAQ
What's the trick in Reaching Points?+
Work backward from (tx, ty). The larger coordinate must have come from subtracting the smaller one, so each state has one parent. Collapse the repeated subtraction with modulo, like Euclid's algorithm. Forward search explodes, reverse is a straight line.
Why does brute force fail here?+
Coordinates go up to 10^9, and each move branches two ways. Forward BFS or DFS blows up exponentially. Even reverse with single subtraction can take about a billion steps when one value is tiny. You need modulo to jump.
What are the edge cases that break solutions?+
Equal coordinates in the target, where no valid parent exists. Modulo overshooting past sx or sy. And the case where one coordinate already matches the start, which needs a divisibility check on the other, not another loop iteration.
How hard is this really?+
Hard on LeetCode terms, but it's a short solution once you see the reverse direction. The code is about ten lines. The difficulty is the insight and the boundary conditions, not the implementation volume.
How do I prepare in 48 hours for this?+
Write the reverse loop from scratch twice. Test it on the two examples, then on cases like (1,1) to (1,10^9) and a target with equal coordinates. Know why modulo is safe and why the final divisibility check is needed.