Flight recorder ring buffer
A drone's flight recorder holds at most capacity telemetry frames in a fixed ring, and you replay the operation log of one flight. An op is either "log|f12", which stores a frame whose payload is the text after the pipe, or "send", which downlinks the oldest frame still held and removes it from the ring. When a log arrives and the ring already holds capacity frames, the write lands on the oldest frame and that frame is lost. A send on an empty ring does nothing. A capacity of zero means the recorder can never hold anything at all. Payloads may repeat. Return the frames still held when the log ends, ordered oldest first.
recorder_frames_left(capacity: int, ops: list[str]) → list[str][3,["log|a","log|b","log|c","log|d"]]out["b","c","d"][2,["log|a","log|b","send","log|c"]]out["b","c"][2,["send","log|a","send","send"]]out[]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.
[3,["log|a","log|b","log|c","log|d"]]["b","c","d"]not run yetsample[2,["log|a","log|b","send","log|c"]]["b","c"]not run yetsample[2,["send","log|a","send","send"]][]not run yetsample