C++ | Simple | map of map | space optimized
simple c++ code with map of map\n\nclass SnapshotArray {\n    unordered_map<int,unordered_map<int,int>> hmap;\n    int snapid=0;\npublic:\n    SnapshotArray(int
simple c++ code with map of map\n```\nclass SnapshotArray {\n    unordered_map<int,unordered_map<int,int>> hmap;\n    int snapid=0;\npublic:\n    SnapshotArray(int length) {\n        \n    }\n    \n    void set(int index, int val) {\n        hmap[snapid][index]=val;\n        \n    }\n    \n    int snap() {\n        snapid++;\n        return snapid-1;\n    }\n    \n    int get(int index, int snap_id) {\n        \n        for(int i=snap_id;i>=0;i--)\n        {\n            if(hmap[i].count(index)==1)\n                return hmap[i][index];\n        }\n        return 0;\n    }\n};```
['C']