HackTheRounds Interview Experiences
Uber SWE OA Interview Experience (2026) - Prime Jumps & Rerooting DP, Offer
Uber SWE 90 minute HackerRank OA: Prime Jumps (DP with sieve of Eratosthenes) and Minimum Edge Reversal (tree rerooting DP). Full walkthrough with Python code a
By Anonymous · 2026-04-08
Background
Finished my Uber SWE OA on March 26 and wanted to put the full walkthrough down while the details were fresh. I have about two years of backend experience at a fintech and applied through the general career site. Uber's OA this cycle is blunt: 90 minutes on HackerRank, two problems, both explicitly Hard DP. There is no warm-up easy and there is no medium. You sit down, read the first prompt, and immediately start sweating.
Timeline
- Application submitted: early March
- OA link received: 12 days later, 5-day window
- OA attempted: March 26
- Recruiter followup: 6 days after submission
- Phone screen: 2 weeks after OA
- Virtual onsite: 3 weeks after phone screen
- Offer: about 8 weeks total
OA Format (90 min, HackerRank)
Two problems, both Hard. Partial credit per test case, so writing a brute force that passes the small inputs is worth attempting even if you cannot reach the optimal. I split my budget as 40 minutes on Problem 1, 45 minutes on Problem 2, and 5 minutes of grace to clean up whichever one was closer to AC.
Problem 1: Prime Jumps
Problem: You start at cell 0 of an array cell[0..n-1] with score 0. On each step you can move right by 1, or move right by p where p is a prime whose last digit is 3 (so 3, 13, 23, 43, 53, 73, 83, ...). When you land on cell i you add cell[i] to your score. Return the maximum score achievable by the time you reach cell n-1 .
Example: cell = [0, -10, -20, -30, 50] . Best path is 0 → 1 → 4 with jumps of 1 then 3, scoring 0 + (-10) + 50 = 40 .
The moment I read "prime whose last digit is 3" I knew there was a sieve step hiding. Cells can be negative, so you cannot just greedily chase the biggest jumps, and you cannot skip the bookkeeping for landing on negative scores that are still on the shortest useful path.
My approach:
- Sieve of Eratosthenes up to `n-1`, then filter primes to those ending in digit 3.
- `dp[i]` = max score achievable landing on cell `i`, with `dp[0] = cell[0]`.
- Transition: `dp[i] = cell[i] + max(dp[i-1], max over valid p of dp[i-p])`.
With n <= 10^4 the inner loop is fine. The count of primes ending in 3 below 10000 is only 300, so total work is roughly 3 10^6 operations, comfortably under the time limit. Do not forget to handle the case where dp[i-1] itself is unreachable — use a negative-infinity sentinel and gate the transition on the incoming state being reachable.
Practice it: [[problem/872?company=12|Prime Jumps]]
Problem 2: Minimum Reversal
Problem: You have an undirected tree given as n-1 edges, but each edge has a stored direction. You must pick a root and flip edges so that every edge points away from the root (from parent to child). Return, for every possible root choice, the minimum number of flips required, then return the overall minimum.
Example: n = 4 , edges 1→4 , 2→4 , 3→4 . Rooting at 2 gives the minimum count of 2 flips.
This is a textbook rerooting problem. If you have never seen rerooting before, Problem 2 is where the OA eats you. I had seen the pattern three times before, so the 45-minute window was enough.
Phase 1: build the adjacency list storing the original direction of each edge. I encoded it as adj[u] = [(v, 0)] if the original edge was u → v , and adj[v] = [(u, 1)] for the reverse view, where the second tuple element is the flip cost from u to v .
Phase 2: pick any node (I used node 0), DFS to compute cost[0] = total flips needed when 0 is the root. While DFSing, also compute subtree cost[v] for every v .
Phase 3: second DFS, this time rerooting. When you move the root from u to adjacent v : - If the original edge was u → v (cost 0 from the u-rooted perspective), moving root to v flips that one edge, so cost[v] = cost[u] + 1 . - If the original edge was v → u (cost 1 from u-rooted), moving root to v unflips it, so cost[v] = cost[u] - 1 .
The final answer is min(cost) across all nodes. I used an explicit stack instead of recursion because Python recursion at n = 10^5 will hit the default limit; a RecursionError during the 89th minute will ruin you. The interviewer on a follow-up round asked about exactly this choice, so it was worth flagging.
Practice it: [[problem/873?company=12|Minimum Edge Reversals to Root a Tree]]
What I Learned from the OA
Two Hard DPs in 90 minutes is a very different test from Meta's two Mediums or Amazon's OA2 simulation. The questions reward pattern recognition over raw coding speed. If you have not seen rerooting before, you will spend most of Problem 2 rederiving the incremental update from scratch, and that is the gap between offer and reject.
Phone Screen (45 min)
One coding problem. I got a variant of Top K Frequent Elements with a twist: ties broken by lexicographic order of the element's string representation, and a streaming constraint where you only see elements one at a time. I solved it with a min-heap of size K plus a secondary comparator. The interviewer asked how I would handle a heavy hitter appearing after the heap is full. The answer is to compare incoming count against the heap min, then swap. Clean 25 minute solve, and then we talked about how it would change if K were dynamic, which turns it into a more interesting data structure problem that I sketched but did not code.
Onsite Preview
Four rounds: two coding, one system design (Design Uber Ride Matching), and a behavioral. The design round was exactly what you would expect, and I leaned on Haversine + geohashing + the dispatcher actor model. The coding rounds were easier than the OA, mostly medium stack and hashmap problems. The behavioral was light compared to Meta or Amazon.
Result
L4 offer. Compensation landed at the expected levels.fyi band for the role. Recruiter was fast, about 4 days from final round to verbal.
Tips
- Drill rerooting specifically before Uber's OA. Uber has asked some version of "count edge flips to root a tree" multiple times this year. If you only know standard tree DP, you will get stuck computing the cost at a single root and run out of time. Practice the incremental update explicitly.
- Sieve + digit filter is a repeat Uber trick. The prime-jumps variant has been reused with different digit filters and different jump rules. Precompute the primes once outside the DP loop, never inside.
- Use iterative DFS in Python for HackerRank. Uber's HackerRank OA does not raise the recursion limit, and Problem 2 constraints are past the default 1000. A `RecursionError` during the 89th minute will ruin you.
- Budget 40 and 45, not 45 and 45. Problem 1 is the closer shave for most people, so get it to a working brute force fast and come back to optimize. Do not start Problem 2 with less than 40 minutes on the clock.
- Do not chase the optimal on both problems. Partial credit on a working O(n^2) rerooting beats a half-written O(n) one. HackerRank scores every visible test case.
- After the OA, email the recruiter with your thinking. I wrote a short note explaining the approach for Problem 2 in case the judge was stricter than expected. It probably did not change anything but it felt like insurance.