Python Binary Search
\nclass RLEIterator:\n\n    \n        # 5:33pm 1/19/2021 \n        # 5:43pm 80% \n        # sounds similar to log rate limiter and 528 random pick with weight\n
```\nclass RLEIterator:\n\n    \n        # 5:33pm 1/19/2021 \n        # 5:43pm 80% \n        # sounds similar to log rate limiter and 528 random pick with weight\n        # we need to record current n\n    def __init__(self, A: List[int]):\n        self.ind = []\n        self.vals = []\n        self.cur_n = 0\n        \n        i = 0\n        cur_acc = 0\n        \n        while i < len(A):\n            if A[i] != 0:\n                cur_acc += A[i]\n                self.ind.append(cur_acc)\n                self.vals.append(A[i+1])\n            i += 2\n        \n\n    def next(self, n: int) -> int:\n        self.cur_n += n\n        \n        if not self.ind:\n            return -1\n        \n        ind = bisect.bisect_left(self.ind, self.cur_n)\n        \n        if ind == len(self.ind):\n            return -1\n        \n        return self.vals[ind]\n\n\n# Your RLEIterator object will be instantiated and called as such:\n# obj = RLEIterator(A)\n# param_1 = obj.next(n)\n```
[]