Code RoomMVCC snapshot isolation visibility
HardPrep Room Coding #301

MVCC snapshot isolation visibility

CodingAlgorithms & data structuresMid–Senior~30 min

Implement an MVCC visibility check under snapshot isolation. versions is a list of [key, value, committed_at] — committed row versions, each stamped with the commit timestamp. A reading transaction has a snapshot timestamp 'snap': it sees, for each key, the version with the GREATEST committed_at that is strictly less than or equal to snap. queries is a list of keys to read. Return a list of [key, value] for each query in order, using the visible version; if no version is visible for a key, use the value 'MISSING'. Assume committed_at values for a key are distinct.

Implement
mvcc_read(versions: list[list], snap: int, queries: list[str]) → list[list]
Examples
in[[["x","v1",10],["x","v2",20]],15,["x"]]out[["x","v1"]]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 30 min
InputExpectedGot
[[["x","v1",10],["x","v2",20]],15,["x"]][["x","v1"]]not run yetsample