Optimistic concurrency control

Write codeMedium25 minOracle and Snowflake style

Your task

Simulate optimistic concurrency control with version numbers. Each record starts at version 0. ops is a list of [txn_id, key, read_version] applied in order: the transaction read 'key' when it had version read_version and now wants to write. The write COMMITS only if the key's current version still equals read_version (no one wrote in between); on commit the key's version increments by 1. Otherwise the write ABORTS and the version is unchanged. Return a list of [txn_id, 'commit' | 'abort'] in op order.

Examples

occ_simulate(ops: list[list]) -> list[list]
Example 1
Inputocc_simulate([[1, "x", 0], [2, "x", 0]])
Output[[1, "commit"], [2, "abort"]]