C++ Solution | Hash Map | Simple
\nclass SnapshotArray {\n    vector<unordered_map<int, int>> data;\npublic:\n    SnapshotArray(int length) {\n        data.push_back(unordered_map<int, int>());
```\nclass SnapshotArray {\n    vector<unordered_map<int, int>> data;\npublic:\n    SnapshotArray(int length) {\n        data.push_back(unordered_map<int, int>());\n    }\n    \n    void set(int index, int val) {\n        data[data.size() - 1][index] = val;\n    }\n    \n    int snap() {\n        int current = data.size() - 1;\n        data.push_back(data[current]);\n        return current;\n    }\n    \n    int get(int index, int snap_id) {\n        if (data[snap_id].find(index) == data[snap_id].end()) {\n            return 0;\n        }\n        return data[snap_id][index];\n    }\n};\n```
[]