JavaScript Solution - O(n) Time and O(1) Space
\nvar RLEIterator = function(encoding) {\n    this.index = 0;\n    this.encoding = encoding;\n};\n\nRLEIterator.prototype.next = function(n) {\n    while (n > 0
```\nvar RLEIterator = function(encoding) {\n    this.index = 0;\n    this.encoding = encoding;\n};\n\nRLEIterator.prototype.next = function(n) {\n    while (n > 0 && this.index < this.encoding.length) {\n\n        const count = this.encoding[this.index];\n        const num = this.encoding[this.index + 1];\n\n        if (count < n) {\n            n -= count;\n            this.index += 2;\n        } else {\n            this.encoding[this.index] = count - n;\n            return num;\n        }\n    }\n    \n    return -1;\n};\n ```
['JavaScript']