[c++] clean solution using map
cpp\nclass SnapshotArray {\npublic:\n    unordered_map<int, map<int, int>> m; // { index : { snap_id_ : val }}\n    int snap_id_ = 0;\n\n    SnapshotArray(int l
```cpp\nclass SnapshotArray {\npublic:\n    unordered_map<int, map<int, int>> m; // { index : { snap_id_ : val }}\n    int snap_id_ = 0;\n\n    SnapshotArray(int length) {}\n\n    void set(int index, int val) {\n        m[index][snap_id_] = val;\n    }\n\n    int snap() {\n        return snap_id_++;\n    }\n\n    int get(int index, int snap_id) {\n        auto itr = m[index].upper_bound(snap_id);\n        if (itr == m[index].begin()) return 0;\n        return (*prev(itr)).second;\n    }\n};\n```
['C', 'Binary Tree']