Solution DeathEVIL
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass SnapshotArray {\npublic:\n    vector<unordered_map<int,int>>A;\n    int snap_id= -1;\n\n    SnapshotArray(int length) {\n        A.clear();\n        A=vector<unordered_map<int,int>>(length);\n        \n    }\n    \n    void set(int index, int val) {\n        A[index][snap_id]=val;\n        \n    }\n    \n    int snap() {\n        snap_id++;\n        return snap_id;\n        \n    }\n    \n    int get(int index, int snap_id) {\n        int temp=snap_id-1;\n        while(temp>=-1)\n        {\n            if(A[index].find(temp)==A[index].end())\n            {\n                temp--;\n            }\n            else\n            {\n                return A[index][temp];\n            }\n        }\n\n        return 0;\n\n        \n    }\n};\n```
['C++']