Flight recorder ring buffer
Your task
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.
Examples
recorder_frames_left(capacity: int, ops: list[str]) -> list[str]Example 1
Input
recorder_frames_left(3, ["log|a", "log|b", "log|c", "log|d"])Output
["b", "c", "d"]Example 2
Input
recorder_frames_left(2, ["log|a", "log|b", "send", "log|c"])Output
["b", "c"]Example 3
Input
recorder_frames_left(2, ["send", "log|a", "send", "send"])Output
[]