Using Deque | O(1) pick
IntuitionWe have to evenly pick numbers, so we can think of Data structure which can give us number from front/back and we can store it in the back/front.Approa
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
We have to evenly pick numbers, so we can think of Data structure which can give us number from front/back and we can store it in the back/front.
# Approach
<!-- Describe your approach to solving the problem. -->
So, Luckily we have deque to perform push_front(), push_back(), pop_front() and pop_back()
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(1) for pick() and O(min(n-1,1e5)) for solution
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(min(n,100000))
# Code
```cpp []
class Solution {
    deque<int> q;
public:
    Solution(int n, vector<int>& blacklist) {
        int mini=min(n-1,100001);
        vector<bool> vis(n,false);
        for(auto i:blacklist){
            if(i<n) vis[i]=true;
        }
        for(int i=0; i<=mini; i++){
            if(i<n && !vis[i]) q.push_front(i);
        }
    }
    
    int pick() {
        int top = q.front();
        q.pop_front();
        q.push_back(top);
        return top;
    }
};

/**
 * Your Solution object will be instantiated and called as such:
 * Solution* obj = new Solution(n, blacklist);
 * int param_1 = obj->pick();
 */
```
['C++']