[Python3/Python] Simple brute force method. Readable solution with comments.
\nclass RLEIterator:\n\n    def __init__(self, encoding: List[int]):\n        \n        # Init\n        self.__x = [] # Elements\n        self.__nums_x = [] # N
```\nclass RLEIterator:\n\n    def __init__(self, encoding: List[int]):\n        \n        # Init\n        self.__x = [] # Elements\n        self.__nums_x = [] # Number of occurence of respective Elements\n        self.__i = 0 # Current index from where one should start consuming\n        \n        for i in range(0,len(encoding),2):\n            if encoding[i] > 0: # Discard any element with zero or less encoding\n                self.__nums_x.append(encoding[i])\n                self.__x.append(encoding[i+1])\n        \n        self.__m = len(self.__x) # No. of elements\n        return\n        \n\n    def next(self, n: int) -> int:\n        \n        res = -1\n        \n        while n:\n            \n            # If index is greater or equal to no. of element\n            # the array is exhausted, break and return -1\n            if self.__i >= self.__m:\n                res = -1\n                break\n            else:\n                \n                # Get the current index\n                k = self.__i\n                \n                # Get the current element\n                res = self.__x[k]\n                \n                # If no. of occurrence of an element is\n                # greater than the number of element to be\n                # consumed, then update the no. of occurrence\n                # of an element to be n less than the current value.\n                # Make n "0" as all slots are consumed.\n                if self.__nums_x[k] > n:\n                    self.__nums_x[k] -= n\n                    n = 0\n                else:\n                    \n                    # If no. of occurrence of an element is\n                    # less or equal than the number of element to be\n                    # consumed, then update the n to be \n\t\t\t\t\t# less than no. of occurrence of the current element.\n                    # Make no. of occurence of current element "0".\n                    # Update the index, to indicate consumption of next element.\n                    n -= self.__nums_x[k]\n                    self.__nums_x[k] = 0\n                    self.__i = self.__i + 1\n                    \n        return res\n        \n\n\n# Your RLEIterator object will be instantiated and called as such:\n# obj = RLEIterator(encoding)\n# param_1 = obj.next(n)\n```
['Python', 'Python3']