← Uber Interview Insights

Uber·Machine Learning Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Uber MLE coding round, one problem the whole time. Geometry-flavored optimization question that looks deceptively clean until you start thinking about what K actually buys you.

Questions Asked (1)

Q1

Given N people on a 2D grid and K pickup locations you can place anywhere, minimize the total Manhattan distance from each person to their nearest pickup point.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

First thing I did was ask whether the pickup locations had to sit on integer coordinates or be chosen from existing people's positions, which felt like the right move.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints (N, K, coordinate ranges) and discussing the NP-hardness of the continuous K-median problem. Then present a practical solution using Lloyd's algorithm with Manhattan distance (K-medians), and optionally mention approximation algorithms or heuristics for large-scale settings.

Pro tip: Acknowledge that Manhattan distance makes the problem separable in x and y, so you can optimize each dimension independently using 1D K-medians, which is a key insight for efficient solutions.

1. Clarify constraints and problem nature

Ask about N, K, coordinate ranges, and whether pickup points can be placed anywhere (continuous) or at discrete locations. Note that the problem is NP-hard for general K.

2. Discuss exact vs. approximate solutions

For small N and K, mention dynamic programming or exhaustive search. For large-scale, propose approximation algorithms like K-medians clustering or local search.

3. Leverage Manhattan distance separability

Explain that Manhattan distance decomposes into independent x and y components, so the problem reduces to two 1D K-median problems, which can be solved optimally in polynomial time using dynamic programming.

4. Present a practical algorithm

Describe Lloyd's algorithm adapted for Manhattan distance (K-medians): initialize centroids, assign points to nearest centroid, update centroids to median of assigned points, and iterate until convergence.

5. Analyze trade-offs and scalability

Compare time complexity, convergence guarantees, and quality of solutions. Discuss how to handle large N with sampling or streaming approaches, and mention evaluation metrics.

Key Points to Mention

  • NP-hardness of the K-median problem in 2D
  • Separability of Manhattan distance into x and y dimensions
  • 1D K-medians can be solved optimally with dynamic programming
  • Lloyd's algorithm (K-medians) for practical clustering
  • Approximation guarantees (e.g., constant-factor approximations)
  • Scalability considerations for large N (sampling, parallelization)

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