Java solution, re-index blacklisted numbers
Calculate effective length\n- Put all blacklisted numbers in map\n- loop all blacklisted numbers, create a variable to track last value to index to\n\t- if nume
- Calculate effective length\n- Put all blacklisted numbers in map\n- loop all blacklisted numbers, create a variable to track last value to index to\n\t- if numebr is larger than effective length, skip\n\t- if last value is blacklisted as well, move one position back\n\t- re-index\n\n- when pick, get a random number within effective length. \n- If it is blacklisted, use re-indexed number.\n- If not, return directly.\n\n\n```java\nclass Solution {\n    private final int size;\n    private final Map<Integer, Integer> valueToIndexMap;\n    \n    public Solution(int n, int[] blacklist) {\n        size = n - blacklist.length;\n        valueToIndexMap = new HashMap<>();\n        \n        // leverage the map as a source of O(1) lookup for blacklist values\n        for(int value : blacklist) {\n            valueToIndexMap.put(value, Integer.MAX_VALUE);\n        }\n        \n        int lastValue = n-1;\n        for(int value : blacklist) {\n            // if already in ignored section\n            if(value >= size) {\n                continue;\n            }\n            \n            // if blacklist value in [0, size), index to a non-blacklisted value in [size, N)\n            // Skip any blacklist values in the end\n            while(valueToIndexMap.containsKey(lastValue)) {\n                lastValue--;\n            }\n            \n            valueToIndexMap.put(value, lastValue);\n            lastValue--;\n        }\n    }\n    \n    public int pick() {\n        Random random = new Random();\n        int randomInt = random.nextInt(size);\n        return valueToIndexMap.getOrDefault(randomInt, randomInt);\n    }\n}\n```
[]