Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Separate start and end times into two sorted arrays. Use two pointers to sweep through time: when a meeting starts, increment rooms needed; when one ends, decrement. Track the maximum rooms needed at any point. This is equivalent to a line sweep algorithm.
Sorting starts and ends separately lets us process events in chronological order. A start event before the earliest pending end means we need an additional room. Processing ends independently works because we only care about the count of concurrent meetings, not which specific meetings overlap.
Updated Feb 2026