O(B) for init, O(1) for pick using idea of remapping
python\nclass Solution:\n\n    def __init__(self, N, blacklist):\n        """\n        :type N: int\n        :type blacklist: List[int]\n        """\n        bl
```python\nclass Solution:\n\n    def __init__(self, N, blacklist):\n        """\n        :type N: int\n        :type blacklist: List[int]\n        """\n        blacklist = set(blacklist)\n        self.length = N - len(blacklist)\n        self.remap = {}\n        need_remap = [x for x in blacklist if x < self.length]\n        j = 0\n        for i in range(self.length, N):\n            if i not in blacklist:\n                self.remap[need_remap[j]] = i\n                j += 1\n            \n    def pick(self):\n        """\n        :rtype: int\n        """\n        idx = random.randrange(self.length)\n        return self.remap[idx] if idx in self.remap else idx\n\n\n# Your Solution object will be instantiated and called as such:\n# obj = Solution(N, blacklist)\n# param_1 = obj.pick()\n```
[]