My first instinct was to overcomplicate this with intervals.
Clarify the problem constraints and edge cases, then use a difference array or sweep line approach to compute attendance per hour in O(n + 24) time. Convert each timestamp to an hour index, apply +1 for arrivals and -1 for departures at that hour, then prefix sum to get attendance per hour and track the maximum.
Pro tip: Mention that you would handle departures before arrivals within the same hour if the problem implies that a departure at HH:MM means the person leaves at the start of that hour, or clarify the exact semantics with the interviewer to avoid off-by-one errors.
Ask whether timestamps are inclusive, how to handle multiple events at the same time, and whether attendance should be computed at the start or end of each hour. Confirm the output format (e.g., peak count only or also the hour).
Use a difference array of size 25 (hours 0-23 plus a sentinel) to record net changes per hour. Alternatively, sort events and sweep, but the difference array is simpler and O(n + 24).
For each event, parse the hour from HH:MM, then increment the difference array for ARRIVAL and decrement for DEPARTURE at that hour. After processing all events, compute prefix sums to get attendance at each hour.
Iterate through the attendance array to find the maximum value. If needed, also track the hour(s) where the peak occurs. Return the peak attendance count.
Walk through a small example, including cases with no events, all arrivals, all departures, and events at the same hour. Verify that the peak is computed correctly.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.