JAVA Solution using HashMap
\nclass Solution {\n    \n    HashMap<Integer,Integer> hm;\n    Random r;\n    int top;\n    public Solution(int n, int[] blacklist) {\n        hm=new HashMap<>
```\nclass Solution {\n    \n    HashMap<Integer,Integer> hm;\n    Random r;\n    int top;\n    public Solution(int n, int[] blacklist) {\n        hm=new HashMap<>();\n        r=new Random();\n        top=n-blacklist.length;\n        \n        HashSet<Integer> hs=new HashSet<>();\n        for(int val:blacklist)\n            hs.add(val);\n        \n        n--;\n        for(int i=0;i<blacklist.length;i++){\n            if(blacklist[i]<top){\n                while(hs.contains(n)){\n                    n--;\n                }\n                \n                hm.put(blacklist[i],n);\n                n--;\n            }\n        }\n    }\n    \n    public int pick() {\n     int randix=r.nextInt(top);\n     if(hm.containsKey(randix)){\n         return hm.get(randix);\n     }\n        \n        return randix;\n    }\n}\n\n/**\n * Your Solution object will be instantiated and called as such:\n * Solution obj = new Solution(n, blacklist);\n * int param_1 = obj.pick();\n */\n```
['Java']