Versioned key-value store
Your task
Implement a versioned key-value store with copy-on-write snapshots. Operations: ["put", key, value] writes to the live (current) version; ["snapshot"] freezes the current state and returns a snapshot id (0 for the first snapshot, 1 for the second, ...), later writes must NOT affect already-taken snapshots; ["get", snapshot_id, key] reads key from the state as it was at that snapshot (-1 if the key was absent there); ["getlive", key] reads from the current live state (-1 if absent). Return a list with one entry per get and getlive operation, in order (snapshot operations are not added to the result list). Keys are strings, values are integers.
Examples
cow_store(ops: list[list]) -> list[int]Example 1
Input
cow_store([["put", "a", 1], ["snapshot"], ["put", "a", 2], ["get", 0, "a"], ["getlive", "a"]])Output
[1, 2]