JS solution
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```javascript []
/**
 * @param {number[]} encoding
 */
var RLEIterator = function(encoding) {
    this.arr = encoding
    
    this.itrSum = 0
    this.itrPtr = 0
};

/** 
 * @param {number} n
 * @return {number}
 */
RLEIterator.prototype.next = function(n) {
	// PRODUCE
    this.itrSum += n
    
	// IF ABOVE LIMIT CONSUME
    while (this.arr[this.itrPtr] < this.itrSum) {
        this.itrSum -= this.arr[this.itrPtr]
        this.itrPtr += 2
    }
    
	// OUT OF BOUNDS
    if (this.itrPtr >= this.arr.length) {
        return -1
    }
    
	// RETURN NEXT
    return this.arr[this.itrPtr+1]
};

/** 
 * Your RLEIterator object will be instantiated and called as such:
 * var obj = new RLEIterator(encoding)
 * var param_1 = obj.next(n)
 */
```
['JavaScript']