Good Ways to Reach a Sum
Reported by candidates from Uber's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Uber's August OA included a graph traversal problem where you need to find all valid paths or ways to reach a target sum. You're looking at a backtracking or DFS pattern disguised as a combinatorial search. Candidates blank here because the problem reads simple but requires you to explore multiple branches and track state. StealthCoder catches the pattern instantly if you freeze mid-approach.
Pattern and pitfall
The core trick is recognizing this as a path-finding problem where each decision branches into multiple possibilities. You'll use depth-first search or backtracking to explore all routes, pruning when the sum exceeds or undershoots your target. The graph structure means you're either navigating node relationships or treating the problem as a tree of choices. Common pitfall: over-optimizing too early or forgetting to backtrack state properly. When the OA timer ticks down and you're stuck on the branching logic, StealthCoder feeds you the exact traversal pattern Uber expects.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Good Ways to Reach a Sum 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 StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as combination sum. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Uber's OA.
Uber 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.
Good Ways to Reach a Sum FAQ
Is this really a graph problem or does it feel like DP?+
It's graph traversal with backtracking as the core. DP would cache results, but here you're exploring all paths explicitly. The hint points to graph, so trust that. DFS with state rollback is the pattern.
What's the trick to not time out?+
Prune aggressively. If your current sum exceeds the target, stop exploring that branch. If you're using a choice array, ensure you're not revisiting states needlessly. Early termination is faster than optimized recursion.
Do I need to track the actual path or just count ways?+
The title says 'ways,' which suggests counting. But verify by reading the output format carefully. If they want the paths themselves, store them during backtracking. Either way, the traversal pattern stays the same.
Can I iterate or do I have to recurse?+
Recursion is cleaner for backtracking problems like this. An iterative stack-based approach works too, but you'll spend more time managing state. Uber's assessments favor the recursive, cleaner solution.
How do I prep in 48 hours if I've never done backtracking?+
Practice one classic: combinations sum or word ladder. Understand the call stack and when to undo changes. The pattern repeats. Knowing when to backtrack is 80% of the work here.