Document version conflicts

Write codeEasy15 minFigma style

Your task

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.

Examples

refused_save_ids(attempts: list[str]) -> list[str]
Example 1
Inputrefused_save_ids(["s1|intro|0", "s2|intro|0", "s3|intro|1"])
Output["s2"]
Example 2
Inputrefused_save_ids(["s1|notes|0", "s2|pricing|0", "s3|notes|1"])
Output[]
Example 3
Inputrefused_save_ids(["s1|intro|3"])
Output["s1"]