PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates understanding of interval overlap, resource allocation and the ability to implement efficient scheduling algorithms for meeting-room assignment.

  • easy
  • Google
  • Coding & Algorithms
  • Software Engineer

Compute minimum rooms for time intervals

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Technical Screen

You are given a list of meeting time intervals, where each interval is represented as `[start, end)` (start time inclusive, end time exclusive) and `start < end`. Two meetings overlap if one starts before the other ends. **Task:** Return the minimum number of conference rooms required so that all meetings can be held without conflicts. ### Input - `intervals`: an array of `n` intervals, each interval is a pair of integers `[start, end)`. ### Output - An integer: the minimum number of rooms needed. ### Constraints (typical interview constraints) - `1 <= n <= 10^5` - `0 <= start < end <= 10^9` ### Example - Input: `[[0,30],[5,10],[15,20]]` - Output: `2` (because at time 5–10, two meetings overlap)

Quick Answer: This question evaluates understanding of interval overlap, resource allocation and the ability to implement efficient scheduling algorithms for meeting-room assignment.

You are given a list of meeting time intervals, where each interval is represented as [start, end). The start time is inclusive and the end time is exclusive. Return the minimum number of conference rooms required so that all meetings can be held without conflicts. Two meetings overlap if one starts before the other ends. Because the end time is exclusive, a meeting that ends at time t does not conflict with a meeting that starts at time t. The intervals may be given in any order.

Constraints

  • 1 <= len(intervals) <= 10^5
  • 0 <= start < end <= 10^9
  • Intervals may be unsorted

Examples

Input: [[0, 30], [5, 10], [15, 20]]

Expected Output: 2

Explanation: The meeting [0,30) overlaps with both [5,10) and [15,20), but [5,10) and [15,20) do not overlap each other. At most 2 rooms are needed.

Input: [[1, 2]]

Expected Output: 1

Explanation: Only one meeting exists, so one room is enough.

Input: [[1, 4], [4, 5], [5, 7]]

Expected Output: 1

Explanation: Each meeting starts exactly when the previous one ends. Since end times are exclusive, they do not overlap, so a single room can be reused.

Input: [[2, 5], [2, 3], [2, 4], [3, 6]]

Expected Output: 3

Explanation: From time 2 to 3, three meetings are active: [2,5), [2,3), and [2,4). At time 3, [2,3) ends exactly as [3,6) starts, so the maximum remains 3.

Input: [[7, 10], [2, 4], [4, 7]]

Expected Output: 1

Explanation: Even though the intervals are unsorted, they form a chain of non-overlapping meetings: [2,4), [4,7), [7,10). One room is sufficient.

Hints

  1. Try sorting all start times and all end times separately, then sweep through time.
  2. If the next meeting starts at or after the earliest ending meeting, that room can be reused because intervals are [start, end).
Last updated: Apr 19, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Build Prefix Lookup with a Trie - Google (medium)
  • Find Common Free Time Slots Across Calendars - Google (easy)
  • Deterministic Task Execution Order - Google (easy)
  • Busiest Rental Car - Google (easy)
  • Count Clusters of 2D Points Within a Radius - Google (medium)