← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
Apr 2026Remote

Summary

Uber SWE interview with a clustering optimization problem. The whole thing was basically one meaty algorithmic question dressed up as a product scenario, and the expected answer was way more nuanced than just writing a loop.

Questions Asked (1)

Q1

Given the coordinates of N people, choose K shuttle pickup locations to minimize the total L1 distance from each person to their nearest pickup location. How would you approach this?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

I knew k-means from college but kept second-guessing whether the median vs mean distinction actually mattered here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints and then propose a solution that leverages the separability of L1 distance into independent x and y coordinates. Explain that the problem reduces to a 1D k-median clustering on each dimension, and discuss algorithms like dynamic programming or greedy approaches for the 1D case, noting that the 2D problem is NP-hard in general.

Pro tip: Mention that while the 2D problem is NP-hard, the 1D k-median can be solved optimally in polynomial time, and for large-scale systems like Uber, approximation algorithms or heuristics (e.g., k-means++ with L1) are often used in practice.

1. Clarify constraints and assumptions

Ask about the size of N and K, whether K is fixed or variable, if locations must be chosen from given points or can be arbitrary, and if there are any real-time constraints.

2. Reduce to 1D subproblems

Explain that L1 distance decomposes into independent x and y components, so the total cost is the sum of costs in each dimension. Thus, we can solve two separate 1D k-median problems.

3. Solve 1D k-median optimally

Describe a dynamic programming approach: sort points, precompute costs for any interval, and use DP to partition into K clusters minimizing sum of distances to medians. Time complexity O(N^2 K) or O(N K) with optimizations.

4. Combine dimensions and handle 2D

Note that solving each dimension independently gives a set of x-coordinates and y-coordinates for facilities, but the pairing into 2D points may not be optimal. Discuss that the 2D problem is NP-hard, so we might use heuristics or approximation algorithms.

5. Discuss practical trade-offs

Mention scalability: for large N, use approximation algorithms like k-means++ adapted for L1, or greedy facility location. Also consider if K is small, brute force over combinations might be feasible.

Key Points to Mention

  • L1 distance separability into x and y coordinates
  • 1D k-median problem and dynamic programming solution
  • NP-hardness of 2D k-median and need for approximation
  • Time and space complexity trade-offs
  • Real-world scalability considerations for Uber's scale
  • Alternative approaches like greedy algorithms or local search

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