Python Remapping
Find the blacklist elements need to remap(not in the tailpart);\nFind the available tail elements to remap and remap with the previous blacklist elements in a d
Find the blacklist elements need to remap(not in the tailpart);\nFind the available tail elements to remap and remap with the previous blacklist elements in a dict\n\n\n```\nclass Solution:\n\n    def __init__(self, n: int, blacklist: List[int]):\n        blacklist = set(blacklist)\n        self.length = n - len(blacklist)\n        self.remap = {}\n        need_remap = []\n        \n        for x in blacklist:\n            if x < self.length:\n                need_remap.append(x)\n        \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\n    def pick(self) -> int:\n        idx = random.randrange(self.length)\n        return self.remap[idx] if idx in self.remap else idx\n\n\n\n```
[]