HackTheRounds Interview Experiences

Uber SWE OA 2026: Two Hard HackerRank Dynamic Programming Problems with Full Solutions

Complete breakdown of Uber's 2026 SWE Online Assessment: Prime Jumps (DP + Sieve) and Minimum Edge Reversals (Tree DP with Rerooting).

By HackTheRounds Team · 2026-04-05

Overview

Uber's 2026 SWE Online Assessment uses HackerRank with a 70-minute time limit and 2 hard problems . This OA is notably harder than most — both questions require advanced algorithmic knowledge beyond standard LeetCode medium.

---

Problem 1: Prime Jumps

Difficulty: Hard | Topics: Dynamic Programming, Sieve of Eratosthenes

Starting from square 0 with score 0, you can move right 1 cell or jump exactly p cells where p is a prime ending in 3 (3, 13, 23, 43...). Landing on cell i adds cell[i] to your score. Return the maximum score to reach cell n-1 .

Example: cell = [0, -10, -20, -30, 50] → Output: 40 (path: 0→1→4)

Approach: Sieve to find primes ending in 3, then DP where dp[i] = max(dp[i-1], dp[i-p] for valid primes p) + cell[i] .

Practice: [[problem/872?company=12|Prime Jumps]]

---

Problem 2: Minimum Edge Reversals to Root a Tree

Difficulty: Hard | Topics: Tree DP, Rerooting

Given a directed tree with n nodes, choose a root to minimize edge reversals so all edges point away from root.

Example: n=4 , edges 1→4, 2→4, 3→4 → Output: 2

Approach: Two-pass DFS rerooting. First DFS counts reversals for root=1. Second DFS propagates: moving root from parent to child adjusts the count in O(1).

Practice: [[problem/873?company=12|Minimum Edge Reversals]]

---

Uber OA Prep Tips

  1. Expect LeetCode Hard level — standard Medium prep isn't enough
  2. Key topics: DP with preprocessing, Tree DP/rerooting, Graph edge manipulation
  3. 35 min per problem — practice speed on hard problems
  4. Partial credit counts — brute force that passes some cases beats an empty solution

Browse all Uber interview questions on HackTheRounds.