C++ | Binary Search | Faster than100%
\n#define ll long long int\nclass RLEIterator {\npublic:\n    vector<ll> prefix,val;\n    ll idx;\n    RLEIterator(vector<int>& en) {\n        ll sum = 0;\n    
```\n#define ll long long int\nclass RLEIterator {\npublic:\n    vector<ll> prefix,val;\n    ll idx;\n    RLEIterator(vector<int>& en) {\n        ll sum = 0;\n        for(int i=0;i<en.size()-1;i+=2){\n            sum += en[i];\n            prefix.push_back(sum);\n            val.push_back(en[i+1]);\n        }\n        idx = 0;\n    }\n    \n    int next(int n) {\n        idx += n;\n        auto it = lower_bound(prefix.begin(),prefix.end(),idx);\n        if(it == prefix.end())\n            return -1;\n        return val[it-prefix.begin()];\n    }\n};\n\n/**\n * Your RLEIterator object will be instantiated and called as such:\n * RLEIterator* obj = new RLEIterator(encoding);\n * int param_1 = obj->next(n);\n */\n```
['C', 'Binary Tree']