Recursive approach | no extra space | beats 100% users
Approach\n- Keep a pointer to the index which represents total occurence of front element\n- for next operation check if cuurent element can satisfy it if yes t
# Approach\n- Keep a pointer to the index which represents total occurence of front element\n- for next operation check if cuurent element can satisfy it if yes then reduce its occurence to total element you are removing If not reduce n to amount it can be fullfilled from front number and recursively call again\n\n# Code\n```\nclass RLEIterator {\npublic:\n    vector<int> enc;int pointer;\n    RLEIterator(vector<int>& e) {\n        enc = e;\n        pointer=0;\n    }\n    \n    int next(int n) {\n        if(pointer>=enc.size())return -1;\n        if(n<=enc[pointer]) {\n            enc[pointer] = enc[pointer]-n;\n            return enc[pointer+1];\n        }\n        n = n - enc[pointer];\n        enc[pointer]=0;pointer+=2;\n        return next(n);\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++']