Simple and easy to understand C++ solution
\nclass SnapshotArray {\npublic:\n    int n;\n    map<int, int> mp;\n    vector<map<int, int>> v;\n    SnapshotArray(int length) {\n        n = -1;\n    }\n    
```\nclass SnapshotArray {\npublic:\n    int n;\n    map<int, int> mp;\n    vector<map<int, int>> v;\n    SnapshotArray(int length) {\n        n = -1;\n    }\n    \n    void set(int index, int val) {\n        mp[index] = val;\n    }\n    \n    int snap() {\n        n++;\n        v.push_back(mp);\n        return n;\n    }\n    \n    int get(int index, int snap_id) {\n        return v[snap_id][index];\n    }\n};\n\n```
['C']