Snapshottable array
Design SnapshotArray(length), an array initialized to zeros that supports:
set(index, val), writevalatindexin the current (uncommitted) version.snap(), take a snapshot; return its id (0, then1, ...) and advance the counter.get(index, snap_id), return the value atindexat the time snapshotsnap_idwas taken.
arr = SnapshotArray(3)
arr.set(0, 5)
arr.snap() # -> 0
arr.set(0, 6)
arr.get(0, 0) # -> 5 (value when snapshot 0 was taken)
Make get run in where m is the number of writes to that index.
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.