Python3 deque solution
Intuition\n Describe your first thoughts on how to solve this problem. \nUse a deque in python to add from right in init function and consume from left in next 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nUse a deque in python to add from right in init function and consume from left in next function. \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(N) for init and O(1) for next\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(N)\n\n# Code\n```\nclass RLEIterator:\n\n    def __init__(self, encoding: List[int]):\n        self.qrle = deque()\n        n = len(encoding)\n        for i in range(0, n, 2):\n            count, elem = encoding[i], encoding[i+1]\n            if count:\n                self.qrle.append((count, elem))    \n\n    def next(self, n: int) -> int:\n        last_elem = 0\n        while n:\n            if not self.qrle:\n                last_elem = -1\n                break\n                \n            count, elem = self.qrle.popleft()\n            if count >= n:\n                last_elem = elem\n                if count > n: self.qrle.appendleft((count-n, elem))\n                break\n            else:\n                n -= count\n        \n        return last_elem\n\n\n# Your RLEIterator object will be instantiated and called as such:\n# obj = RLEIterator(encoding)\n# param_1 = obj.next(n)\n```
['Python3']