#126

Hotel Reservations Max Revenue

MEDIUMSweep LinePYTHON

Problem Description

A revenue analytics pipeline for a property booking platform must identify the peak revenue window — the time interval where the sum of revenue from all concurrent active bookings is greatest. This sweep line pattern generalizes to any interval-weighted overlap problem in event processing. Given a list of reservations, find the maximum-revenue overlap window. **Input:** A list `reservations` of tuples `(time_range, revenue)` where `time_range` is a string like `"2-4"` (start hour to end hour) and `revenue` is an integer. **Output:** A tuple `(max_revenue, start_hour, end_hour)` identifying the window with the highest total concurrent revenue. **Key Rules:** - Revenue from all reservations active during `[start, end]` is summed. - On ties for max revenue, return the earliest-starting window. - Hours are integers in range 0–24.

Topics

array

Asked at Companies

airbnb

Solve This Problem

Sign up to access the interactive code editor, run test cases, view the editorial, and get AI-powered feedback on your solution.

Start Solving →