Short and Easy c++ solution
\n\n\nclass RLEIterator {\npublic:\n    \n    int mp;\n    vector<int> arr;\n    RLEIterator(vector<int>& encoding) {\n        mp=0;\n        arr.clear();\n    
\n\n```\nclass RLEIterator {\npublic:\n    \n    int mp;\n    vector<int> arr;\n    RLEIterator(vector<int>& encoding) {\n        mp=0;\n        arr.clear();\n        for(int i=0;i<encoding.size();i++){\n            arr.emplace_back(encoding[i]);\n        }\n    }\n    \n    int next(int n) {\n        \n        while(mp<arr.size()){\n            if(arr[mp]-n>=0){\n                arr[mp]-=n;\n                return arr[mp+1];\n            }\n            else{\n                n= n-arr[mp];\n                mp+=2;\n            }\n        }\n        \n        return -1;\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```\n
[]