← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Uber coding interview with a staircase optimization problem that looks deceptively simple until you realize the walking cost is energy-dependent and the whole thing needs a binary search approach. Pretty niche problem, not your typical LeetCode grind.

Questions Asked (1)

Q1

You have a staircase of N floors. You can take an elevator for the first x floors (gaining energy and spending fixed time per floor), then walk the rest (spending energy and spending time that depends on your current energy). Find the value of x that minimizes total time.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The energy-dependent walking cost is what makes this tricky.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the total time as a function of x by defining the elevator time and walking time, then find the minimum using binary search or ternary search on the convex function. Discuss the trade-offs between elevator and walking, and justify the choice of algorithm based on monotonicity or convexity.

Pro tip: Clarify assumptions about the energy-time relationship early, as it determines whether the function is convex; if not, consider dynamic programming or other optimizations. Also, mention edge cases like x=0 or x=N to ensure robustness.

1. Define Variables and Functions

Clearly define the elevator time function E(x) and walking time function W(x), including how energy affects walking time. State any assumptions about monotonicity or convexity.

2. Formulate Total Time

Express total time T(x) = E(x) + W(x) and analyze its properties, such as convexity or monotonicity, to determine the appropriate optimization method.

3. Choose Optimization Technique

If T(x) is convex, use ternary search; if monotonic, use binary search. Otherwise, consider dynamic programming or other approaches, and justify your choice.

4. Implement and Test

Write pseudocode for the chosen method, handle edge cases (x=0, x=N), and test with sample inputs to verify correctness and efficiency.

5. Analyze Complexity and Trade-offs

Discuss time and space complexity, and compare with alternative approaches. Mention practical considerations like integer constraints and precision.

Key Points to Mention

  • Convexity of the total time function and its implications for optimization
  • Binary search vs. ternary search: when to use each based on monotonicity or convexity
  • Energy-time trade-off: how walking time depends on remaining energy
  • Edge cases: x=0 (all walking) and x=N (all elevator)
  • Time complexity: O(log N) for binary/ternary search vs. O(N) for brute force
  • Assumptions about elevator time and energy gain: linear or constant per floor

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.