Race Car
A hard-tier problem at 44% community acceptance, tagged with Dynamic Programming. Reported in interviews at Anduril and 1 others.
Race Car is a hard dynamic programming problem that shows up in assessments at Anduril and Turing. With a 44% acceptance rate, most candidates who attempt it walk away wrong. The trick isn't obvious: you can't just greedily accelerate and reverse. The car's velocity compounds every step, and the cost of backtracking explodes fast. You need to frame this as a shortest-path problem where state is position and velocity, then DP your way to the minimum button presses. If this one hits your live online assessment and you blank on the velocity dimension, StealthCoder surfaces a working solution in seconds, invisible to the proctor.
Companies that ask "Race Car"
Race Car 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. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.
Get StealthCoderThe core insight: at each step, you can either accelerate (velocity increases by 1) or reverse (velocity flips sign, position stays put). Naive greedy fails because you can't see far enough ahead to know when reversing saves total moves. The state space is (position, velocity), and you need DP or BFS to find the minimum. Common pitfall is treating this as a simple math problem when it's actually a graph search with compressed state. The obvious mistake is assuming you can always accelerate then reverse cleanly, but the math of compounding velocity makes that expensive. Dynamic programming with memoization, or BFS with careful state management, both work. The hard part is recognizing the state representation and that velocity isn't just a side effect, it's the core constraint. When you're under time pressure on the assessment and the greedy approach feels wrong, StealthCoder runs invisibly and hands you the DP formulation.
Pattern tags
You know the problem.
Make sure you actually pass it.
Race Car recycles across companies for a reason. It's hard-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. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Race Car interview FAQ
Why does greedy acceleration not work here?+
Greedy assumes full speed ahead then reverse, but velocity grows exponentially. Reversing from high velocity costs many button presses. DP explores lower-velocity paths that might reach the target in fewer total moves. The problem requires seeing trade-offs greedy can't model.
Is this actually asked at FAANG or big tech?+
Anduril and Turing have both asked it. It's rarer than array or tree problems, but it appears in harder assessment rotations. Don't expect it everywhere, but don't be surprised either.
What's the key state representation?+
State is (position, velocity). Velocity doesn't reset; it compounds. Every button press changes it by 1 or flips its sign. This two-dimensional state space is what makes DP necessary instead of math shortcuts.
How does this relate to Dynamic Programming fundamentals?+
It's a classic DP optimization problem. You're minimizing cost (button presses) over exponentially many paths. Memoization collapses redundant subproblems. If you've drilled coin change or jump game, the DP pattern is familiar; the state definition is what's tricky here.
How long should this take if I know the trick?+
If you recognize it as a shortest-path DP problem, 15 to 25 minutes to code and test. If you don't see the state representation immediately, you'll spin on greedy approaches. That's where most candidates lose time.
Want the actual problem statement? View "Race Car" on LeetCode →