← Uber Interview Insights

Uber·Software Engineer·Onsite - Coding / Algorithms·Senior

Senior
Jun 2026

Summary

Uber SWE interview that was basically one big scheduling problem dressed up in five different costumes. The core question was approachable but the follow-ups kept coming and by the end I was just trying to hold it together on concurrency.

Questions Asked (6)

Q1

Given N attendees with busy calendars and individual working-hour windows, find the earliest time slot of at least d minutes where everyone is free simultaneously. Return the start time or -1 if none exists.

Algorithms & Data Structures
Author's notes

I went with a merge-intervals approach: combine all busy intervals across attendees, sort them, then scan the gaps.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model each attendee's busy intervals as half-open intervals [start, end) and clip them to their working hours. Merge all busy intervals across attendees to find global free intervals, then scan for the earliest free interval of length at least d minutes. Return the start time of that interval or -1 if none exists.

Pro tip: Clarify edge cases upfront: whether working-hour windows are inclusive, how to handle meetings that span outside working hours, and whether d is in minutes or another unit. Also mention that the solution should be efficient for large N, so avoid O(N^2) pairwise comparisons.

1. Clarify inputs and constraints

Confirm the format of busy intervals and working hours, the unit of d, and edge cases like empty calendars or meetings outside working hours. Ask about expected input size to choose the right algorithm.

2. Normalize and clip intervals

For each attendee, clip their busy intervals to their working-hour window, discarding any parts outside. This ensures all intervals are within the relevant time range.

3. Merge all busy intervals

Collect all clipped busy intervals from all attendees, sort them by start time, and merge overlapping or adjacent intervals. This yields a set of global busy blocks.

4. Find free intervals and check duration

Compute the gaps between merged busy intervals (and before the first/after the last) within the overall working-hour range. For each gap, check if its length is at least d minutes.

5. Return earliest valid slot or -1

Scan gaps in chronological order and return the start time of the first gap that satisfies the duration requirement. If none, return -1.

Key Points to Mention

  • Interval representation: use half-open intervals [start, end) to avoid ambiguity at boundaries.
  • Clipping busy intervals to working hours to ignore irrelevant times.
  • Merging intervals: sort by start time and merge overlapping/adjacent intervals.
  • Time complexity: O(M log M) where M is total number of busy intervals, dominated by sorting.
  • Edge cases: no busy intervals, d larger than any free gap, meetings spanning multiple days.
  • Scalability: handling large N by avoiding pairwise comparisons and using efficient sorting/merging.

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

Q2

How does your algorithm generalize from 2 to N attendees, and what changes in time and space complexity?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Pretty natural extension once the merge step is already written.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by restating the problem for N attendees and the algorithm's core idea, then explain how the algorithm naturally extends from 2 to N by generalizing the data structures and loops. Analyze time and space complexity as functions of N, comparing to the 2-attendee case, and discuss trade-offs or optimizations.

Pro tip: Emphasize that the generalization often involves replacing pairwise comparisons with scalable data structures (e.g., heaps, hash maps) and that complexity analysis should consider both average and worst cases, as interviewers at Uber care about real-world scalability.

1. Restate the problem and algorithm

Briefly restate the problem for N attendees and summarize the algorithm's approach for 2 attendees, highlighting key operations.

2. Generalize the algorithm

Explain how to extend the algorithm to N attendees, focusing on changes in data structures, loops, and logic to handle arbitrary N.

3. Analyze time complexity

Derive the time complexity as a function of N, compare to the 2-attendee case, and discuss best, average, and worst cases.

4. Analyze space complexity

Determine the space complexity as a function of N, noting any additional memory required for the generalized approach.

5. Discuss trade-offs and optimizations

Mention potential trade-offs (e.g., time vs. space) and possible optimizations or alternative approaches for large N.

Key Points to Mention

  • Generalization from 2 to N: replacing pairwise comparisons with scalable data structures (e.g., heaps, hash maps, or sorting).
  • Time complexity: often O(N log N) or O(N^2) depending on the algorithm, and how it scales compared to O(1) or O(N) for N=2.
  • Space complexity: additional memory for storing N attendees or auxiliary data structures, e.g., O(N) or O(N^2).
  • Trade-offs: balancing time and space, and considering constraints like memory limits or real-time processing.
  • Edge cases: N=0, N=1, and very large N, and how the algorithm handles them.
  • Optimizations: using efficient data structures, early termination, or approximation algorithms for large N.

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

Q3

Attendees are in different time zones with different working hours per local day. How do you normalize times correctly, including handling daylight saving time transitions?

Technical Trade-offsSystem Design
Author's notes

This one tripped me up more than I expected.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying that you would store all timestamps in UTC and convert to local time zones only for display or scheduling logic. Then explain how to use a robust time zone library (e.g., IANA tz database) to handle DST transitions, and discuss trade-offs like performance, correctness, and edge cases such as ambiguous or skipped times.

Pro tip: Mention that you would store the user's time zone identifier (e.g., 'America/New_York') alongside their profile, not just an offset, because offsets change with DST. Also, highlight that you would test DST edge cases explicitly, as they are a common source of bugs.

1. Clarify requirements and constraints

Ask whether the system needs to schedule events, display times, or compute durations across zones. Confirm if historical or future DST rules matter and if users can change time zones.

2. Choose a canonical time representation

Store all timestamps in UTC (or as epoch time) in the database and backend logic. This avoids ambiguity and simplifies comparisons and arithmetic.

3. Use a reliable time zone database and library

Leverage the IANA tz database via a well-maintained library (e.g., java.time, pytz, moment-timezone) to convert between UTC and local times, ensuring DST rules are applied correctly.

4. Handle DST edge cases explicitly

For ambiguous times (fall back) and non-existent times (spring forward), define a policy: e.g., pick the first occurrence, shift forward, or reject. Document and test these cases.

5. Design for scalability and correctness

Cache time zone conversions if needed, but ensure cache invalidation when tz data updates. Consider using a service like Google's Time Zone API for up-to-date rules, and monitor for DST-related bugs.

Key Points to Mention

  • Store timestamps in UTC and convert to local time only when needed for display or scheduling.
  • Use IANA time zone identifiers (e.g., 'America/Los_Angeles') instead of fixed offsets.
  • Leverage a robust time zone library that handles DST transitions automatically.
  • Explicitly handle ambiguous and skipped times during DST transitions with a defined policy.
  • Consider performance implications of frequent time zone conversions and caching strategies.
  • Test DST edge cases thoroughly, including historical and future transitions.

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

Q4

Schedules can have up to around a million total intervals across all attendees. How do you keep the solution efficient when inputs are this large and highly fragmented?

Algorithms & Data StructuresSystem Design
Author's notes

Talked about keeping the sort-and-scan approach since it's already linear after sorting.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints and expected operations (e.g., finding free slots, detecting conflicts). Then propose an efficient algorithm like sweep line with sorting, and discuss how to handle fragmentation using data structures such as interval trees or segment trees. Finally, address scalability with distributed processing or streaming if needed.

Pro tip: Mention that you would first check if the intervals are already sorted or can be bucketed by time granularity, as this can drastically reduce complexity. Also, emphasize the importance of choosing the right data structure based on the most frequent operation.

1. Clarify Requirements and Constraints

Ask about the specific operations needed (e.g., find common free slots, detect overlaps) and the expected output format. Confirm the scale (1M intervals) and whether intervals are static or dynamic.

2. Choose an Efficient Algorithm

Propose a sweep line algorithm: sort all interval endpoints (2M points) and sweep to compute overlaps or free slots in O(N log N) time. Alternatively, use an interval tree for dynamic queries.

3. Optimize for Fragmentation and Scale

If intervals are highly fragmented, consider bucketing by time units (e.g., minutes) and using a bitset or segment tree to represent availability. For distributed scale, partition by time ranges or attendees.

4. Analyze Trade-offs and Edge Cases

Discuss time vs. space trade-offs: sorting is O(N log N) but requires memory; bucketing is O(N) but may use large memory. Handle edge cases like overlapping intervals, zero-length intervals, and timezone differences.

5. Summarize and Validate

Recap the chosen approach, its complexity, and why it fits the scale. Mention potential optimizations like parallel sorting or using a database with interval indexing.

Key Points to Mention

  • Sweep line algorithm with sorting endpoints
  • Interval trees or segment trees for dynamic queries
  • Time bucketing and bitset representation for fragmentation
  • Complexity analysis: O(N log N) time, O(N) space
  • Distributed processing or streaming for very large inputs
  • Trade-offs between different data structures and algorithms

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

Q5

Redesign the function so it only considers slots after the current time, without accepting 'now' as a direct parameter. How do you handle testability and determinism?

API & IntegrationsTechnical Trade-offs
Author's notes

Clock injection.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by acknowledging the need to remove 'now' as a parameter to simplify the API, then propose injecting a clock abstraction (e.g., a Clock interface) to provide the current time. Explain how this maintains testability by allowing mock clocks in tests and determinism by controlling time in test scenarios. Emphasize the trade-offs and how this pattern aligns with dependency injection principles.

Pro tip: Mention that using a clock abstraction not only aids testing but also supports multiple time zones and avoids hidden dependencies, which is crucial for a global service like Uber. Also, note that you can provide a default system clock for production to keep the API clean.

1. Clarify the requirement

Restate the problem: the function should only consider slots after the current time, but 'now' should not be a direct parameter. This means the function must obtain the current time internally, but in a way that is testable and deterministic.

2. Introduce a clock abstraction

Propose injecting a clock dependency (e.g., an interface with a Now() method) into the function or its containing class. This decouples time retrieval from the function's logic and allows substitution in tests.

3. Ensure testability and determinism

Explain that in tests, you can inject a mock clock that returns a fixed time, making tests deterministic. In production, you inject the system clock. This avoids flaky tests and allows precise control over time-dependent behavior.

4. Address API design and trade-offs

Discuss how this changes the function signature (no 'now' parameter) and the implications: cleaner API, but requires dependency injection. Mention alternatives like using a global clock (less testable) or passing a time provider as a parameter (defeats the purpose).

5. Summarize benefits and considerations

Conclude that the clock abstraction improves testability, determinism, and maintainability. Note that it may require refactoring and that the team should agree on the pattern for consistency.

Key Points to Mention

  • Dependency injection of a clock interface to avoid direct time dependency.
  • Mocking the clock in tests to return a fixed time for deterministic tests.
  • Using the system clock in production for real-time behavior.
  • Trade-offs: cleaner API vs. added complexity of dependency injection.
  • Avoiding global state or singletons for time to prevent hidden dependencies.
  • Consideration of time zones and clock skew in distributed systems.

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

Q6

Calendars can be updated concurrently while a meeting-finder call is running. How do you keep reads consistent and writes safe? Walk through your choice of locking strategy, data structures, and how you avoid starvation.

System DesignTechnical Trade-offs
Author's notes

Hardest part of the whole interview.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the consistency requirements and scale, then propose a strategy that balances read consistency and write safety, such as MVCC for reads and fine-grained locking for writes. Walk through the data structures (e.g., interval trees, versioned calendars) and locking mechanisms (e.g., row-level locks, optimistic concurrency) while addressing starvation via fair queuing or timeout-based escalation.

Pro tip: Emphasize that the meeting-finder is a read-heavy operation, so optimizing for read consistency without blocking writes is key; mention that you'd use a snapshot isolation level to avoid read locks entirely, which also helps with starvation.

1. Clarify Requirements and Constraints

Ask about consistency needs (e.g., can the meeting-finder tolerate slightly stale data?), scale (number of concurrent updates), and latency requirements. This determines whether you need strong consistency or can use eventual consistency.

2. Choose a Locking Strategy

Decide between pessimistic locking (e.g., two-phase locking) and optimistic concurrency control (e.g., version numbers). For read-heavy workloads, consider MVCC to allow reads without blocking writes.

3. Design Data Structures

Propose structures like interval trees for efficient overlap queries, and versioned calendars or immutable snapshots to support consistent reads. Explain how updates create new versions without affecting ongoing reads.

4. Address Starvation and Fairness

Describe mechanisms to prevent starvation, such as fair queuing for lock acquisition, timeout-based lock escalation, or prioritizing long-waiting transactions. Mention that MVCC inherently reduces starvation by eliminating read locks.

5. Discuss Trade-offs and Alternatives

Compare your approach with alternatives (e.g., global locks vs. fine-grained locks) and explain why your choice is optimal for the given constraints. Highlight trade-offs in complexity, performance, and consistency.

Key Points to Mention

  • MVCC (Multiversion Concurrency Control) for consistent reads without blocking writes
  • Fine-grained locking (e.g., per-calendar or per-time-slot locks) to reduce contention
  • Optimistic concurrency control with version numbers or timestamps for writes
  • Interval trees or similar data structures for efficient meeting overlap queries
  • Starvation avoidance via fair lock acquisition (e.g., FIFO queues) or timeout mechanisms
  • Snapshot isolation to provide a consistent view of calendars during the meeting-finder call

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