[C++] Binary Search | Easy to understand solution
\n/* \n    Time:\n            O(1) | set\n            O(1) | snap\n            O(logn) | get, where n is number of snaps taken on that index\n    Space: O(n*i),
```\n/* \n    Time:\n            O(1) | set\n            O(1) | snap\n            O(logn) | get, where n is number of snaps taken on that index\n    Space: O(n*i), where i is length of array n is maximum number of snaps taken\n    Tag: Binary Search (Upper Bound)\n    Difficulty: M\n*/\n\nclass SnapshotArray {\n    vector<vector<pair<int, int>>>updates;\n    int curSnap;\n\npublic:\n    SnapshotArray(int length) {\n        updates.resize(length);\n        curSnap = 0;\n    }\n\n    void set(int index, int val) {\n        if (!updates[index].empty() && updates[index].back().first == curSnap)\n            updates[index].back().second = val;\n        else\n            updates[index].push_back({curSnap, val});\n    }\n\n    int snap() {\n        curSnap++;\n        return curSnap - 1;\n    }\n\n    int get(int index, int snap_id) {\n        int idx = upper_bound(updates[index].begin(), updates[index].end(), make_pair(snap_id,INT_MAX)) - updates[index].begin();\n        if (idx == 0) return 0;\n        return updates[index][idx - 1].second;\n    }\n};\n\n/**\n * Your SnapshotArray object will be instantiated and called as such:\n * SnapshotArray* obj = new SnapshotArray(length);\n * obj->set(index,val);\n * int param_2 = obj->snap();\n * int param_3 = obj->get(index,snap_id);\n */\n```
['C', 'Binary Tree', 'C++']