1# Runtime: 64 ms (Top 41.88%) | Memory: 14.5 MB (Top 71.25%)2class RLEIterator:34def __init__(self, encoding: List[int]):5self.encoding = encoding67def next(self, n: int) -> int:89if self.encoding:1011count = self.encoding[0]1213if count >= n:14# Partially exhaust and return the current value.15self.encoding[0] -= n16return self.encoding[1]1718# Exhaust all of current value and continue.19self.encoding = self.encoding[2:]20return self.next(n - count)2122return -1