Solve Prime Jumps and Pipeline Scaling
Company: Uber
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Overview: This question evaluates algorithmic problem-solving skills in constrained path optimization and resource-allocation throughput maximization, including concepts such as graph modelling with prime-step constraints, dynamic programming, number-theoretic reasoning, and combinatorial optimization.
Read the full Uber Software Engineer interview experience this question came from
Part 1: Prime-Constrained Score Jump
Constraints
- 1 <= len(score) <= 5000
- -100000 <= score[i] <= 100000
- 0 <= k <= 5000
- A jump length must be prime, so length 1 is not allowed.
Examples
Input: ([5, -2, 4, 10, -1], 3)
Expected Output: 8
Explanation: Valid jump lengths are 2 and 3. The only way to reach index 4 is 0 -> 2 -> 4, giving 5 + 4 - 1 = 8.
Input: ([10, -100, -5, 20, 1, 50], 3)
Expected Output: 80
Explanation: The best path is 0 -> 3 -> 5 using jumps of length 3 and 2, for a total of 10 + 20 + 50 = 80.
Hints
- First generate all prime jump lengths up to min(k, len(score) - 1).
- Use dynamic programming: let dp[i] be the best total score achievable when landing on index i.
Part 2: Maximize Pipeline Throughput
Constraints
- 1 <= len(t) == len(cost) <= 100000
- 1 <= t[i] <= 1000000
- 1 <= cost[i] <= 1000000
- 0 <= budget <= 1000000000000
- Each service can be expanded only an integer number of times.
Examples
Input: ([10, 20, 30], [5, 10, 15], 10)
Expected Output: 20
Explanation: Spend 5 to expand the first service once, raising it to 20. Reaching 25 or more would require also expanding the second service and would exceed the budget.
Input: ([7], [3], 10)
Expected Output: 28
Explanation: With one service, spend at most 10 on expansions costing 3 each. Three expansions are possible, so throughput is 7 * 4 = 28.
Hints
- For a proposed target throughput X, compute the minimum number of expansions each service needs to reach at least X.
- The feasibility of a target throughput is monotonic: if X is affordable, then every smaller target is also affordable.