Java using Interval with Explanation
The idea is simple as follows:\nBased on the given black list, create a range pick for Random.next() as follows:\nFor example: Black List is [2,3,5] and N is 7,
The idea is simple as follows:\nBased on the given black list, create a range pick for Random.next() as follows:\nFor example: Black List is [2,3,5] and N is 7, so our range pick will be;\n[0,2], [4,5], and [6,7].   This is gonna be our Range Pick List. \n\nThen all we need to do is call Random.Next to pick the next Index  (range) from our Range Pick List like Random.Next(list.size())\nand after that based on the range we use this formula:\nRandom.nextInt(EndRange-StartRange)+StartRange\n\n```\n    Random random; int listSize=0;  List<int[]> list;\n    public Solution(int N, int[] blacklist) {\n    \trandom = new Random();\n        Arrays.sort(blacklist);  //Sort the BlackList \n        list = new ArrayList<>();\n        int start=0; int i=0;\n        int len=blacklist.length;\n        while(i<len){        \t// create the Range Pick List\n        \tif(start==blacklist[i]){start++; i++; continue;} \n        \tlist.add(new int[]{start,blacklist[i]});\n        \tstart=blacklist[i]+1;\n        \ti++;\n        }\n        if(start<N) list.add(new int[]{start,N});\n        listSize=list.size(); \n    }\n    \n    public int pick() {\n        int index = random.nextInt(listSize); //Pick the Range Pick List Index First\n        int[] next = list.get(index); // Pick the Range from the list\n        return random.nextInt(next[1]-next[0])+next[0]; //Call any number in the range\n    }\n```
[]