← Google Interview Insights

Google·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Coding round at Google for a software engineer role. Pretty manageable, the main problem was basically Meeting Rooms II dressed up in a taxi dispatch scenario.

Questions Asked (1)

Q1

Given a list of taxi ride requests each with a start and end time, find the minimum number of taxis needed to serve all rides without overlap.

Algorithms & Data Structures
Author's notes

Classic interval scheduling problem underneath the story.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model each ride as an interval and recognize that the minimum number of taxis equals the maximum number of overlapping intervals at any point in time. Use a sweep-line algorithm: create events for start and end times, sort them, and track the count of active taxis, updating the maximum. Alternatively, sort start and end times separately and use two pointers to compute the maximum overlap.

Pro tip: Clarify whether a taxi can immediately take a new ride that starts exactly when the previous ride ends; if not, treat end events as occurring before start events at the same timestamp. This edge case often trips up candidates.

1. Understand the problem

Restate the problem to confirm that rides cannot overlap for the same taxi, and the goal is to minimize the total number of taxis. Ask clarifying questions about edge cases, such as whether a taxi can start a new ride at the exact end time of a previous ride.

2. Choose an approach

Decide between a sweep-line algorithm using events or sorting start and end times separately. Both are O(n log n) time and O(n) space. Explain the intuition: the minimum number of taxis is the maximum number of rides happening simultaneously.

3. Implement the solution

Write code for the chosen approach. For sweep-line: create events (start: +1, end: -1), sort by time (with end before start if needed), iterate and track current and max taxis. For two-pointer: sort starts and ends, iterate with two pointers, increment count on start, decrement on end, and track max.

4. Test with examples

Walk through a simple example, such as rides [(0,30), (5,10), (15,20)], to verify the algorithm returns 2. Also test edge cases: no rides, all rides overlapping, and rides that touch at endpoints.

5. Analyze complexity

State that the time complexity is O(n log n) due to sorting, and space complexity is O(n) for storing events or sorted arrays. Mention that this is optimal for comparison-based sorting.

Key Points to Mention

  • The problem reduces to finding the maximum number of overlapping intervals.
  • Sweep-line algorithm: create events for start and end times, sort, and track active count.
  • Alternative: sort start and end times separately and use two pointers to compute max overlap.
  • Time complexity O(n log n) and space complexity O(n).
  • Edge case: if a taxi cannot take a new ride immediately after finishing, process end events before start events at the same timestamp.
  • The solution is optimal because it matches the lower bound of sorting.

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