Closed out the interval family with Meeting Rooms III โ same sweep, but now the answer needs a specific room number, not just a count.
- Two heaps instead of one:
available(min-heap of empty room ids, so "lowest free room" is a peek away) andbusy(min-heap of(end_time, room_id), same pairing trick as the Meeting Rooms II room-assignment follow-up) - Releasing finished rooms into
availableneeds awhileloop, not anifโ same reasoning as yesterday's Car Pooling: more than one room can finish in the gap between two meetings' start times - The trap: when no room is free, the meeting waits for whichever room frees up soonest, but keeps its ORIGINAL duration โ
freeAt + duration, notfreeAt + endand not the originalend. Easy to grab the wrong variable here count[roomId] += 1works safely right after the if/else because both branches setroomIdbefore that line runs โ whichever branch fired, the count always matches the room actually picked- Folded this into the existing Interval Family post instead of a standalone one โ it's the same sweep-line family as Merge Intervals through Car Pooling, just with a second heap added for identity