Bid lifetime max tracking
An ad exchange records one bid per second for a single slot. The bid that lands in second i is worth amounts[i] cents and stays live for lifetimes[i] seconds, so it can be accepted during seconds i through i + lifetimes[i] - 1. A lifetime of 0 means the bidder pulled it the instant it landed, so it is never live. At the end of every second the exchange publishes the largest amount among the bids still live in that second, or -1 when nothing is live. Return one published number per second, in order. Amounts and lifetimes are never negative, and the two lists have the same length.
live_bid_peaks(amounts: list[int], lifetimes: list[int]) → list[int][[50,90,40],[3,1,2]]out[50,90,50][[70,20],[1,1]]out[70,20][[80,30,30,10],[1,4,1,1]]out[80,30,30,30]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[[50,90,40],[3,1,2]][50,90,50]not run yetsample[[70,20],[1,1]][70,20]not run yetsample[[80,30,30,10],[1,4,1,1]][80,30,30,30]not run yetsample