Find peak flight data
A link monitor replays the trace a sender recorded on one connection and reports how much data sat in flight at the worst moment. Every line of trace is either send:N, meaning the sender put N more bytes on the wire, or ack:K, meaning the receiver has confirmed the first K bytes of the stream counted from the moment the connection opened. Acknowledgements are cumulative, so one whose number is not greater than the highest number already accepted is a duplicate and changes nothing. One whose number is greater than the total bytes sent so far cannot be true and is ignored completely. After every line the unacknowledged amount is the total sent minus the highest accepted acknowledgement. Return the largest unacknowledged amount this connection ever held, or 0 for an empty trace.
peak_unacked_bytes(trace: list[str]) → int[["send:100","send:200","ack:100","send:50"]]out300[["send:10","ack:40","send:100","ack:40"]]out110[["send:500","ack:500"]]out500State 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.
[["send:100","send:200","ack:100","send:50"]]300not run yetsample[["send:10","ack:40","send:100","ack:40"]]110not run yetsample[["send:500","ack:500"]]500not run yetsample