Using Queue. Simple approach.
Complexity\n- Time complexity:\nPreprocessing - O(n)\nQueries - O(1)\n\n- Space complexity:\nO(n)\n\n# Code\n\nclass Solution {\n    queue<int> q;\npublic:\n   
# Complexity\n- Time complexity:\nPreprocessing - O(n)\nQueries - O(1)\n\n- Space complexity:\nO(n)\n\n# Code\n```\nclass Solution {\n    queue<int> q;\npublic:\n    Solution(int n, vector<int>& blacklist) {\n        unordered_set<int> list(blacklist.begin(), blacklist.end());\n        for(int i = 0; i < n; i++){\n            if(list.find(i) == list.end()) q.push(i);\n            if(q.size() == 1e5) break; \n/* As the queries may be upto 2*1e4 then it is wise to just make a queue containing these many numbers. Still 1e5 is just for simplicity. Required because n can be 1e9 which cannot be stored in queue due to MLE. */\n        } \n    }\n    \n    int pick() {\n        int front = q.front();\n        q.pop();\n        q.push(front);\n        return front;\n    }\n};\n```
['C++']