← Google Interview Insights

Google·Software Engineer·Onsite - Coding / Algorithms·Intermediate

IntermediatePrefer not to say
Apr 2026

Summary

Google SWE coding round, got a taxi scheduling problem that's basically Meeting Rooms II with a thin story layered on top. Pretty standard interval scheduling stuff if you've seen it before.

Questions Asked (1)

Q1

Given a list of taxi ride requests, each represented as a time interval [start, end), find the minimum number of taxis needed to serve all requests simultaneously.

Algorithms & Data Structures
Author's notes

Recognized it as Meeting Rooms II pretty fast, which was both good and slightly annoying because it felt like they just renamed the problem and called it a day.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify that this is the classic 'minimum meeting rooms' problem, which can be solved by sorting start and end times separately and using a two-pointer sweep to count concurrent intervals. Alternatively, use a min-heap to track end times of ongoing rides, adding a new taxi only when the earliest ending ride is still in progress. Explain the time and space complexity and discuss edge cases like empty input or zero-length intervals.

Pro tip: Mention that the two-pointer approach is often preferred in interviews for its simplicity and O(n log n) time with O(n) space, but be prepared to discuss the heap approach as it naturally handles streaming data. Also, explicitly state that intervals are half-open [start, end) so a ride ending at time t does not conflict with one starting at t.

1. Clarify the problem and constraints

Confirm that intervals are half-open, ask about input size, and whether the list is sorted. Discuss edge cases such as empty input or zero-length intervals.

2. Choose an approach

Decide between the two-pointer sweep (sort starts and ends separately) or the min-heap method (sort by start time and track end times). Explain why both yield the same result.

3. Walk through the algorithm

For two-pointer: sort starts and ends, iterate through starts, increment count when a start is before the current end, else move the end pointer. For heap: sort by start, push end times into a min-heap, and pop if the earliest end <= current start.

4. Analyze complexity and edge cases

State that both approaches run in O(n log n) time due to sorting and use O(n) space. Test with examples like [[0,30],[5,10],[15,20]] and discuss how the algorithm handles them.

5. Discuss trade-offs and extensions

Compare the two-pointer and heap approaches in terms of code simplicity and adaptability to streaming input. Mention that the heap approach can be extended to find the actual assignment of taxis if needed.

Key Points to Mention

  • The problem is equivalent to finding the maximum number of overlapping intervals at any point in time.
  • Sorting start and end times separately allows a linear sweep to count concurrent intervals.
  • Using a min-heap to track end times of ongoing rides efficiently determines when a taxi becomes free.
  • Half-open intervals [start, end) mean a ride ending at time t does not overlap with one starting at t.
  • Time complexity is O(n log n) due to sorting, and space complexity is O(n) for the sorted arrays or heap.
  • Edge cases include empty input, single ride, and all rides overlapping.

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