Python AC solution with a very simple approach
Firstly make blacklist as set instead of list to O(1) check for forbidden\n Then create another empty set for pre-used numbers\n Define current number (self.cur
* Firstly make blacklist as set instead of list to O(1) check for forbidden\n* Then create another empty set for pre-used numbers\n* Define current number (self.cur) as 0\n* And then in each pick, iterate from current number (self.cur) if possible\n* If current number is within [0, N) return it\n* Else return random number from pre-used numbers\n* In total it is O(N + B) time for setting B set and iterating from 0 to N in the worst case\n```\nclass Solution:\n\n    def __init__(self, N, blacklist):\n        self.forbidden = set(blacklist)\n        self.n = N\n        self.used = set()\n        self.cur = 0\n    def pick(self):\n        while self.cur in self.forbidden:\n            self.cur += 1\n        if self.cur < self.n:\n            num = self.cur\n            self.cur += 1\n        else:\n            num = self.used.pop()\n        self.used.add(num)\n        return num\n```\n* Compressed\n```\nclass Solution:\n\n    def __init__(self, N, blacklist):\n        self.forbidden, self.n, self.used, self.cur = set(blacklist), N, set(), 0\n    def pick(self):\n        while self.cur in self.forbidden: self.cur += 1\n        if self.cur < self.n: num, self.cur = self.cur, self.cur + 1\n        else: num = self.used.pop()\n        self.used.add(num)\n        return num\n```
[]