Skip to content
playdsa
Preferences

Make yourself comfortable.

Saved on this browser. Your device’s reduced-motion preference is always respected.

Theme
Advanced settings

The Hall Allocation

Learn
Play
Prove
Problem context and objectives
Mission briefing

Puzzle systems engineer · A game mechanic is behaving incorrectly

Measure peak simultaneous demand: The Hall Allocation.

Brute force may pass the demo but fail when the world fills with players.

How you win

  1. 1Recognize when Meeting-room sweep line matches the clues
  2. 2Keep this true after every move: active equals meetings started but not yet ended at the current event
  3. 3Reach the result within O(n log n)

Rules and pressure

  • Target cost: O(n log n)
  • State rule: active equals meetings started but not yet ended at the current event
Lesson 1 of 3

Live algorithm trace

Meeting-room sweep line

Complete execution
1 of 6

Separate and sort all start and end events.

1starts = sorted starts; ends = sorted ends
2if next start < next end
3active += 1; advance start
4otherwise active -= 1; advance end
5best = max(best, active)
6return best
starts = [0,5,15]ends = [10,20,30]active = 0
Truth to preserve / Cost target
Truth to preserve

active equals meetings started but not yet ended at the current event

Cost target

O(n log n)

Sort starts and ends separately. The next event either opens a room or frees one; the maximum number of active meetings is the minimum number of rooms required.

Your call · What should guide every step of this algorithm?

Help shape PlayDSA

Something confusing, broken, or missing? Leave a quick note without leaving your lesson.

Please leave out passwords, payment details and other private information.

Page included: /

Sign in to save feedback here, or send it with your email app. Your draft stays here while you sign in.

Open email instead