1# Runtime: 841 ms (Top 10.38%) | Memory: 24.8 MB (Top 56.73%)2class Solution:34def __init__(self, n: int, blacklist: List[int]):5self.hashmap = {}6for b in blacklist:7self.hashmap[b] = -18self.length = n - len(blacklist)9flag = n - 110for b in blacklist:11if b < self.length:12while flag in self.hashmap:13flag -= 114self.hashmap[b] = flag15flag -= 11617def pick(self) -> int:18seed = random.randrange(self.length)19return self.hashmap.get(seed, seed)202122# Your Solution object will be instantiated and called as such:23# obj = Solution(n, blacklist)24# param_1 = obj.pick()