[Python] Beats 97% - without using binary search
\n\n# Code\n\nclass SnapshotArray:\n\n    def __init__(self, length: int):\n        self.snapshots_idx = []\n        self.snapshots = {}\n        self.current =
\n\n# Code\n```\nclass SnapshotArray:\n\n    def __init__(self, length: int):\n        self.snapshots_idx = []\n        self.snapshots = {}\n        self.current = {} \n        self.latest_idx = 0\n\n    def set(self, index: int, val: int) -> None:\n        self.current[index] = val\n        self.latest_idx = len(self.snapshots_idx)\n\n    def snap(self) -> int:\n        if self.latest_idx == len(self.snapshots_idx):\n            self.snapshots[self.latest_idx] = self.current.copy()\n\n        self.snapshots_idx.append(self.latest_idx)\n        return len(self.snapshots_idx) - 1\n\n    def get(self, index: int, snap_id: int) -> int:\n        return self.snapshots[self.snapshots_idx[snap_id]][index] if index in self.snapshots[self.snapshots_idx[snap_id]] else 0\n\n```
['Python3']