Java | 5ms | Simple Solution
Code\n\nclass RLEIterator {\n    int i, len, val = -1;\n    int[] list;\n    public RLEIterator(int[] encoding) {\n        i=0;\n        len = encoding.length;\
# Code\n```\nclass RLEIterator {\n    int i, len, val = -1;\n    int[] list;\n    public RLEIterator(int[] encoding) {\n        i=0;\n        len = encoding.length;\n        list = encoding;\n    }\n    \n    public int next(int n) {\n        if(i >= len-1) return -1;\n\n        int ans = -1;\n        // Reduce the count and return the number\n        if(list[i] - n > 0){\n            list[i] -= n;\n            ans = list[i+1];\n        }\n        // Return the number and  Move iterator to next group\n        else if(list[i] - n == 0){\n            ans = list[i+1];\n            i += 2;    \n        }\n        // Move iterator to next group and recursively call next with n-list[i]\n        else{\n            int newN = n - list[i];\n            i += 2;\n            ans = next(newN);\n        }\n        return ans;\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```
['Java']