← Uber Interview Insights

Uber·Data Scientist·Technical Phone Screen·Senior

Senior
Apr 2026

Summary

Uber data scientist technical screen, basically one big coding and design problem that took the whole session. The question was algorithmically dense and they clearly wanted you to both code it and justify the math, which I was not fully prepared for.

Questions Asked (1)

Q1

Implement a Python function that samples k items without replacement with probability proportional to their weights, given a stream of up to 100 million items. The solution must handle extreme weight values without overflow, support reproducibility via a seed, use O(k) memory, and gracefully reject nonpositive weights. You should also explain the algorithm, prove it's unbiased, discuss numerical stability, and describe how you'd test it.

Algorithms & Data StructuresTechnical Trade-offsSystem Design
Author's notes

This was a lot to hold in your head at once.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and constraints, then propose a streaming algorithm like weighted reservoir sampling (A-ES) that handles extreme weights via log-space arithmetic. Explain the algorithm step-by-step, prove its unbiasedness, discuss numerical stability techniques, and outline a testing strategy including edge cases and statistical validation.

Pro tip: Emphasize that you would use log-space computations to avoid overflow/underflow with extreme weights, and mention that you'd validate the implementation using statistical tests like chi-squared or Kolmogorov-Smirnov on the sampling distribution.

1. Clarify Requirements and Constraints

Restate the problem: sample k items without replacement from a stream of up to 100M items with weights, O(k) memory, reproducibility, and handling of extreme weights and nonpositive weights. Ask clarifying questions about weight distribution, stream characteristics, and performance needs.

2. Choose and Explain the Algorithm

Propose a streaming algorithm such as weighted reservoir sampling (e.g., A-ES or Efraimidis-Spirakis) that maintains a reservoir of k items. Explain how it processes each item, updates the reservoir, and ensures proportional selection without replacement.

3. Address Numerical Stability and Edge Cases

Describe how to handle extreme weights using log-space arithmetic (e.g., log of weights, log-sum-exp) to prevent overflow/underflow. Explain rejection of nonpositive weights and how to incorporate a seed for reproducibility.

4. Prove Unbiasedness and Discuss Complexity

Provide a proof sketch that each item is selected with probability proportional to its weight. Analyze time and space complexity: O(n) time, O(k) memory, and note that log-space operations add constant overhead.

5. Outline Testing Strategy

Describe unit tests for edge cases (zero/negative weights, k > n, extreme weights), statistical tests (chi-squared, KS) to verify distribution, and reproducibility tests with seeds. Mention performance testing on large streams.

Key Points to Mention

  • Weighted reservoir sampling algorithm (e.g., A-ES or Efraimidis-Spirakis) for streaming data
  • Log-space arithmetic (log-sum-exp) to handle extreme weights without overflow/underflow
  • Reproducibility via seeding the random number generator
  • O(k) memory and O(n) time complexity
  • Rejection of nonpositive weights with appropriate error handling
  • Statistical testing (chi-squared, KS) and unit tests for edge cases

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