Java Solution
\nclass Solution {\n    int size = 0;\n    Map<Integer, Integer> valToIndex = new HashMap<>();\n    public Solution(int n, int[] blacklist) {\n        size = n 
```\nclass Solution {\n    int size = 0;\n    Map<Integer, Integer> valToIndex = new HashMap<>();\n    public Solution(int n, int[] blacklist) {\n        size = n - blacklist.length;\n        for (int i : blacklist) {\n            valToIndex.put(i, -1);\n        }\n        int last = n - 1;\n        for(int i : blacklist) {\n\t\t//pay attention to this\n            if (i >= size) {\n                continue;\n            }\n\t\t\t//pay attention to this\n            while(valToIndex.containsKey(last)) {\n                last--;\n            }\n            valToIndex.put(i, last);\n            last--;\n        }\n    }\n    \n    public int pick() {\n        int index = (int) (Math.random() * size);\n        return valToIndex.getOrDefault(index, index);\n    }\n}\n\n```
[]