Key-value snapshots

Write codeMedium30 minSnowflake style

Your task

Implement snapshot and restore over a key-value log. Process a list of operations on a string to int store: ["set", key, value] sets a key; ["del", key] deletes a key (no-op if absent); ["snapshot"] records a named checkpoint, where the name is its 0-based snapshot index (the first snapshot is 0, the second is 1, and so on); ["restore", id] reverts the entire store to the exact state it had at the moment snapshot id was taken (no-op if that snapshot id was never created). After all ops, return the final state as a list of [key, value] pairs sorted ascending by key. <= 10^4 ops.

Examples

snapshot_restore(ops: list[list]) -> list[list]
Example 1
Inputsnapshot_restore([["set", "a", 1], ["snapshot"], ["set", "a", 9], ["restore", 0]])
Output[["a", 1]]