MVCC snapshot visibility

Write codeHard28 minOracle and Snowflake style

Your task

Implement MVCC snapshot visibility for a single row. The row has multiple versions, each given as [version_id, created_ts, deleted_ts] where created_ts is when the version became live and deleted_ts is when it was superseded (use -1 for a version that is still live). A reader with snapshot timestamp snap_ts sees a version if created_ts <= snap_ts AND (deleted_ts == -1 OR deleted_ts > snap_ts). At most one version is visible at any snapshot. Return the version_id of the visible version, or -1 if none is visible. Versions are not pre-sorted.

Examples

mvcc_visible_version(versions: list[list], snap_ts: int) -> int
Example 1
Inputmvcc_visible_version([[1, 0, 10], [2, 10, -1]], 5)
Output1