19 lines C++, O(B) constructor & O(log B) for pick.
\nclass Solution {\n    vector<int> prefix;\n    mt19937 gen;\n    uniform_int_distribution<> dis;\npublic:\n    Solution(int N, vector<int> blacklist): dis(0, 
```\nclass Solution {\n    vector<int> prefix;\n    mt19937 gen;\n    uniform_int_distribution<> dis;\npublic:\n    Solution(int N, vector<int> blacklist): dis(0, N - int(blacklist.size()) - 1) {\n        sort(blacklist.begin(), blacklist.end());\n        for(int i = 0; i < blacklist.size(); i++) {\n            prefix.push_back(blacklist[i] - i);\n        }\n        prefix.push_back(N - blacklist.size());\n    }\n    int pick() {\n        int idx = dis(gen);\n        return idx + (upper_bound(prefix.begin(), prefix.end(), idx) - prefix.begin());\n    }\n};\n```\n\nKey point: `prefix` vector keep the prefix sum of range length for each serial range.\n\nFor example, `N = 10, B = [4, 6, 7]`. So the serial range is: `[0,1,2,3], [5], [], [8,9]` (Keep the empty range). So the prefix range is: `[4, 5, 5, 7]`. \n\nAs for the `pick` function,  it get the index of the number to generate (only `N - len(B)` number left), than it use binary search to find the index of the range this number is in, than the number is it\'s index in the blocked list plus it\'s range index.\nFor example, for `N = 10, B = [4, 6, 7]`, we try to get the 5th numer, as for the blocked list is `[0,1,2,3], [5], [], [8,9]`, this number is in the 3rd range, so it is 8.\n\nI think use Map for this question (the TOP answer) is better, but this solution is not so bad and is much shorter.
[]