← Google Interview Insights

Google·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Google SWE coding round with a scheduling problem that looks deceptively simple until you realize the cyclic clock wraps around midnight and suddenly your interval logic is broken.

Questions Asked (1)

Q1

Given a list of tasks each with a start time and duration in minutes on a 24-hour cyclic clock (tasks can wrap past midnight), find the minimum number of servers needed so every task runs on a dedicated server for its full duration without any overlap.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The example they gave was tasks like (23, 60) which wraps past midnight and that's where I fumbled at first.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model each task as an interval on a circular timeline, then use a sweep-line algorithm with a difference array to count concurrent tasks. Handle wrap-around by splitting tasks that cross midnight into two intervals or by duplicating the timeline. The maximum overlap count is the minimum number of servers needed.

Pro tip: Clarify with the interviewer whether tasks can be scheduled at any time or if start times are fixed; if fixed, the problem reduces to finding maximum overlap. Also, mention that if tasks can be shifted, it becomes a circular interval graph coloring problem, which is more complex.

1. Clarify assumptions and edge cases

Ask if start times are fixed or flexible, and confirm that tasks cannot be preempted. Discuss how to handle tasks that wrap past midnight (e.g., split into two intervals).

2. Choose a representation

Decide between converting times to minutes since midnight and using a difference array, or using an event-based sweep line. For circular handling, consider duplicating the timeline or splitting wrap-around tasks.

3. Design the algorithm

For fixed start times, compute the maximum number of overlapping tasks using a sweep line or difference array. For flexible start times, model as circular interval graph coloring and use a greedy algorithm after sorting by start time.

4. Analyze complexity and trade-offs

Compare time and space complexity of approaches: O(n log n) for sorting-based sweep vs O(n + T) for difference array (T=1440). Discuss trade-offs between simplicity and efficiency.

5. Test with examples

Walk through a small example, including a task that wraps midnight, to verify correctness. Consider edge cases like all tasks overlapping or no overlap.

Key Points to Mention

  • Sweep line algorithm with events (start and end) to count concurrent tasks
  • Difference array technique for fixed time range (0 to 1439 minutes)
  • Handling circular wrap-around by splitting tasks or duplicating the timeline
  • Maximum overlap equals minimum servers needed (interval graph coloring)
  • Time complexity: O(n log n) for sorting, O(n) for sweep; space O(n) or O(1440)
  • If start times are flexible, problem becomes circular interval graph coloring, which may require different approach

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