MediumArraysSortingHeapGreedy

Meeting Rooms II

LeetCode
2 approaches, code in all languages

You are given a list of meeting time intervals, each described by a start and an end time. Determine the smallest number of separate rooms required so that no two overlapping meetings ever have to share a room.

A meeting that ends exactly when another begins does not count as an overlap, so those two meetings can safely reuse the same room.

Example 1

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

Output: 2

The [0,30] meeting overlaps both of the others, so a second room is needed while it runs.

Example 2

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

Output: 1

The two meetings never overlap, so a single room is enough.

Constraints

  • 1 ≤ intervals.length ≤ 10^4
  • 0 ≤ start < end ≤ 10^6
You've got the patterns

Patterns get you through the screen. Shipping gets you hired.

FDE Coach is a cohort-based program in frontend, backend, AWS, and AI where you build real products and get referred to 200+ hiring partners. The free live workshop is the fastest way to see how we teach.

750+ engineers trained · frontend, backend, AWS & AI

August 15 · 0d left
Enroll Now