✅ Explained - Simple and Clear Python3 Code✅
\n\n\n# Code\n\nclass SnapshotArray:\n\n    def __init__(self, length: int):\n        self.saved=[  [] for _ in range(length)]\n        self.unsaved=[]\n       
\n\n\n# Code\n```\nclass SnapshotArray:\n\n    def __init__(self, length: int):\n        self.saved=[  [] for _ in range(length)]\n        self.unsaved=[]\n        self.count=0\n        \n\n    def set(self, index: int, val: int) -> None:\n        self.unsaved.append([index,val])\n        \n\n    def snap(self) -> int:\n        for item in self.unsaved:\n            self.saved[item[0]].insert(0,[self.count, item[1]])\n        self.unsaved.clear()\n        self.count+=1\n        return self.count-1\n        \n\n    def get(self, index: int, snap_id: int) -> int:\n        his=self.saved[index]\n        for i in his:\n            if i[0]<=snap_id:\n                return i[1]\n        return 0\n```
['Python3']