← Uber Interview Insights

Uber·Machine Learning Engineer·Technical Phone Screen·Senior

Senior
Jun 2026

Summary

Uber MLE round with a combinatorics-heavy coding problem. The question had enough edge cases to make you second-guess yourself the whole way through.

Questions Asked (1)

Q1

Given a list of intervals, count the number of unordered triplets (i, j, k) such that all three intervals are pairwise non-overlapping.

Algorithms & Data Structures
Author's notes

The first thing I fumbled was not asking whether endpoints touching counts as overlapping.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First clarify the definition of non-overlapping (e.g., [1,2] and [2,3] are considered non-overlapping if endpoints touch). Then sort intervals by end time and use dynamic programming to count triplets: for each interval as the last one, count pairs of non-overlapping intervals before it. Alternatively, sort by start time and use binary search to find compatible intervals, then count triplets efficiently.

Pro tip: Mention that you can reduce the triplet count to O(n^2) by fixing the middle interval and counting non-overlapping intervals on both sides, or to O(n log n) with prefix sums and binary search. This shows you understand optimization beyond brute force.

1. Clarify the problem

Confirm whether intervals are closed or half-open, and whether touching endpoints count as non-overlapping. Also confirm if intervals are given as [start, end] and if they are sorted.

2. Sort intervals

Sort the intervals by their end times (or start times) to enable efficient counting of non-overlapping intervals.

3. Define DP or counting method

For each interval i, compute the number of intervals that end before i starts (using binary search). Then count triplets by iterating over the middle interval or using prefix sums.

4. Count triplets efficiently

Use the precomputed counts to sum over all possible triplets. For example, for each j, add (number of non-overlapping intervals before j) * (number of non-overlapping intervals after j).

5. Analyze complexity

State the time complexity (e.g., O(n log n) or O(n^2)) and space complexity, and discuss potential optimizations or edge cases.

Key Points to Mention

  • Definition of non-overlapping intervals (end <= start of next)
  • Sorting by end time to enable binary search
  • Using binary search to find the rightmost non-overlapping interval
  • Dynamic programming or prefix sums to count pairs and triplets
  • Time complexity: O(n^2) naive, O(n log n) optimized
  • Handling edge cases: empty list, fewer than 3 intervals, duplicate intervals

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