Live coding: medium LeetCode-level problem on hotel data involving aggregating and windowing.
Asked in the Live coding stage. Code should run; explain what and why.
Given booking records as [hotel_id, date, rooms] and an integer window_days, aggregate rooms for each hotel and date. Return records [hotel_id, date, daily_rooms, rolling_rooms], where rolling_rooms includes the current date and the preceding window_days - 1 calendar days. Missing dates contribute zero. Sort output by hotel_id, then date.
def hotel_rolling_demand(records, window_days):