python3 coroutine beat 100%
The problem is to implement an iterator, my first thought is to use a generator. However, the iterator accepts an input. That will be a python coroutine. \n\n\n
The problem is to implement an iterator, my first thought is to use a generator. However, the iterator accepts an input. That will be a python coroutine. \n\n```\n    def __init__(self, A):\n        """\n        :type A: List[int]\n        """    \n        def my_gen(data):\n            i = 0\n            n = yield\n            while True:\n                try:\n                    count = data[i]\n                    value = data[i + 1]\n                    i += 2\n                except:\n                    yield -1\n\n                while count > 0:\n                    if n <= count:\n                        count -= n\n                        n = yield value\n                    else:\n                        n -= count\n                        count = 0\n                \n        self.gen = my_gen(A)\n        next(self.gen)\n        \n        \n    def next(self, n):\n        """\n        :type n: int\n        :rtype: int\n        """\n        return self.gen.send(n)\n```
[]