Short concise Java solution, beats 97%.
Intuition\nyou cannot decode the original array and loop through it since occurance are of the order 10^9\n# Approach\nProcess the original encoding array, main
# Intuition\nyou cannot decode the original array and loop through it since occurance are of the order 10^9\n# Approach\nProcess the original encoding array, maintain a variable cursor. there will be two cases \nif n > encoding[cursor] , decrement n by encoding[cursor] and proceed\n\nif n <= encoding[cursor] , decrement encoding[cursor] by n and return encoding[cursor+1] (the actual element).\n\nif cursor exceeds arrays length return -1 \n# Complexity\n- Time complexity:\nO(N)\n- Space complexity:\nO(N)\n# Code\n```\nclass RLEIterator {\n    int[] encodingArr;\n    int cursor;\n    public RLEIterator(int[] encoding) {\n        this.encodingArr = new int[encoding.length];\n        for(int i = 0;i<encoding.length;i++){\n            encodingArr[i] = encoding[i];\n        }\n        this.cursor = 0;\n    }\n    \n    public int next(int n) {\n        while(cursor < encodingArr.length){\n            if(encodingArr[cursor] >= n){\n                encodingArr[cursor] -= n;\n                return encodingArr[cursor+1];\n            }else{\n                n -= encodingArr[cursor];\n                cursor +=2;\n            }\n        }\n        return -1;\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```
['Java']