Document version conflicts
A document API guards every write with a version tag. A client loads a document, edits it, then sends the save back stamped with the version it loaded. Each entry in attempts is one save written as "save_id|doc_id|base_version", and the entries are listed in the order the server handled them, which is one interleaving of clients that were editing at the same time. A document nobody has saved yet sits at version 0. The server accepts a save whose base version equals the document's current version, and that document then moves one version higher. Otherwise somebody got there first: the server refuses the save, the document is untouched, and that client must reload and try again later in the log. Documents are independent. Return the refused save ids in arrival order, or an empty list when every save was accepted.
refused_save_ids(attempts: list[str]) → list[str][["s1|intro|0","s2|intro|0","s3|intro|1"]]out["s2"][["s1|notes|0","s2|pricing|0","s3|notes|1"]]out[][["s1|intro|3"]]out["s1"]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.
[["s1|intro|0","s2|intro|0","s3|intro|1"]]["s2"]not run yetsample[["s1|notes|0","s2|pricing|0","s3|notes|1"]][]not run yetsample[["s1|intro|3"]]["s1"]not run yetsample