You're building a simple order monitor. Events arrive in non-decreasing time order (one or more per line, whitespace-separated) and are of two types:
1. Order
order <time> <item> <units> <unit_price>
Records that <units> of <item> were processed at <unit_price> at second <time>.
2. Inspect
inspect <time> <item>
Asks for the total units of <item> and the most recent unit price during the trailing 60-second window (time - 60, time] (orders strictly after time - 60 and at or before time). If no orders for <item> fall in the window, return 0 0.
For each inspect, append exactly one line to the output:
window-rollup <time> <item> <units_total> <latest_price>
Function signature
python def processEvents(events: List[str]) -> List[str]: ...
events is a list of strings; each string may contain multiple whitespace-separated event tokens. Process tokens left-to-right. Output lines must appear in the same order as the corresponding inspect events.
Rules
time is a non-negative integer; times never decrease across the input.<item> is an uppercase alphabetic string.<units> and <unit_price> are positive integers.T, the window is (T - 60, T] — orders at exactly T - 60 are excluded; orders at exactly T are included.Example 1
Input:
order 7 COFFEE 40 5 order 12 COFFEE 70 6 order 28 TEA 25 3 order 35 COFFEE 15 7 inspect 67 COFFEE order 72 TEA 30 4 inspect 95 COFFEE inspect 95 TEA
Output:
window-rollup 67 COFFEE 85 7 window-rollup 95 COFFEE 0 0 window-rollup 95 TEA 30 4
Explanation:
inspect 67 COFFEE: window (7, 67] includes COFFEE orders at t=12 (70u) and t=35 (15u). Total = 85, latest price = 7.inspect 95 COFFEE: window (35, 95] has no COFFEE orders. Output 0 0.inspect 95 TEA: window (35, 95] includes TEA at t=72 (30u). Total = 30, latest price = 4.Example 2 (multiple events per line)
Input:
order 3 SODA 10 2 inspect 3 SODA order 63 SODA 5 3 inspect 63 SODA inspect 64 SODA
Output:
window-rollup 3 SODA 10 2 window-rollup 63 SODA 5 3 window-rollup 64 SODA 5 3
(At T=63, window is (3, 63] — excludes the order at exactly t=3, includes the order at t=63.)