Python short and clean.
Approach\nTL;DR, Similar to Editorial solution.\n\n# Complexity\n- Time complexity:\n    __init__, set, snap: O(1)\n    get: O(log(snap\_id))\n\n- Space complex
# Approach\nTL;DR, Similar to [Editorial solution](https://leetcode.com/problems/snapshot-array/editorial/).\n\n# Complexity\n- Time complexity:\n    `__init__, set, snap`: $$O(1)$$\n    `get`: $$O(log(snap\\_id))$$\n\n- Space complexity:\n    `__init__, snap, get`: $$O(1)$$ after `n` calls.\n    `set`: $$O(n)$$ after `n` calls.\n\n# Code\n```python\nclass SnapshotArray:\n\n    def __init__(self, length: int):\n        self.id = 0\n        self.history = defaultdict(lambda: [[self.id, 0]])\n\n    def set(self, index: int, val: int) -> None:\n        h = self.history[index]\n        if  self.id > h[-1][0]: h.append([self.id, val])\n        else: h[-1][1] = val\n\n    def snap(self) -> int:\n        self.id += 1\n        return self.id - 1\n\n    def get(self, index: int, snap_id: int) -> int:\n        snap_index = bisect_right(self.history[index], snap_id, key=itemgetter(0))\n        return self.history[index][snap_index - 1][1]\n\n\n```
['Hash Table', 'Binary Search', 'Design', 'Python', 'Python3']