710. Random Pick with Blacklist
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    int totalSize;
    vector<int> availableNums;

    Solution(int n, vector<int>& blocked) {
        n = min(100000, n);
        unordered_set<int> blockedSet(begin(blocked), end(blocked));
        for (int i = 0; i < n; ++i) {
            if (blockedSet.find(i) == blockedSet.end()) {
                availableNums.push_back(i);
            }
        }
        totalSize = availableNums.size();
    }

    int pick() {
        int randomIndex = rand() % totalSize;
        return availableNums[randomIndex];
    }
};

```
['C++']