22 line python beats 95%
snapArr is a list of dictionary, each dictionary records the time when value is set for the particular index. The key in the dictionary is the given version and
`snapArr` is a list of dictionary, each dictionary records the time when value is set for the particular index. The key in the dictionary is the given version and the value is the `val`.\nTake `[{1: 2, 10: 4}, {9:12} ]` as example, if we want to find version 5 for index 0, it would be 2 because between version 1 and version 10, the value at index 1 has always been 2.\n```\nclass SnapshotArray:\n    def __init__(self, length: int):\n        self.cur_ver = 0\n        self.snapArr = [{} for _ in range(length)]\n        \n    def set(self, index: int, val: int) -> None:\n        self.snapArr[index][self.cur_ver] = val\n        \n    def snap(self) -> int:\n        self.cur_ver += 1\n        return self.cur_ver - 1\n    \n    def get(self, index: int, snap_id: int) -> int:\n        if snap_id in self.snapArr[index]:\n            return self.snapArr[index][snap_id]\n        last_val = 0\n        for i in range(0, self.cur_ver+1):\n            if i in self.snapArr[index]:\n                last_val = self.snapArr[index][i]\n            if i >= snap_id:\n                return last_val\n        return last_val\n
[]