Python solution with comments [24ms]
The idea is to keep track of the current counter/value. I have a temp value that stores how much of the current value has been "next" but not completely done ye
The idea is to keep track of the current counter/value. I have a temp value that stores how much of the current value has been "next" but not completely done yet. This makes it easier when I need to move the counter.\n```\nclass RLEIterator(object):\n\n    def __init__(self, A):\n        """\n        :type A: List[int]\n        """\n        self._counts = A[0::2]\n        self._vals = A[1::2]\n        self._index = 0 # the current index of the iteration\n        self._next = 0 # how many next has been called on the current value\n        self._len = len(self._vals)\n        \n\n    def next(self, n):\n        """\n        :type n: int\n        :rtype: int\n        """\n\n        remains = self._next + n\n        # Moving the counter based on how many next elements we have to skip.\n        while self._index < self._len and remains > self._counts[self._index] :\n            remains -= self._counts[self._index]\n            self._index += 1\n                \n        # already run out\n        if self._index >= self._len:\n            return -1\n        else:\n            self._next = temp\n            return self._vals[self._index]\n```
[]