Simple C++ solution
\nclass RLEIterator {\npublic:\n    \n    int curInd;\n    vector<int> seq;\n    \n    RLEIterator(vector<int>& A) {\n        seq = A;\n        curInd = 0;\n   
```\nclass RLEIterator {\npublic:\n    \n    int curInd;\n    vector<int> seq;\n    \n    RLEIterator(vector<int>& A) {\n        seq = A;\n        curInd = 0;\n    }\n    \n    int next(int n) {\n        while (curInd < seq.size()){\n            if (seq[curInd]>=n){\n                seq[curInd]-=n;\n                return seq[curInd+1];\n            }else{\n                n -= seq[curInd];\n                curInd += 2;\n            }\n        }\n        return -1;\n    }\n};\n```
[]