class Solution {
Map<Integer,Integer> b2w=new HashMap<>();
int bound=0;
Random random=new Random();
public Solution(int n, int[] blacklist) {
bound=n-blacklist.length;
Set<Integer> black=new HashSet<>();
for(int b:blacklist){
if(b>=bound){
black.add(b);
}
}
int w=bound;
for(int b:blacklist){
if(b<bound){
while(black.contains(w)){
w++;
}
b2w.put(b,w);
w++;
}
}
}
public int pick() {
int x=random.nextInt(bound);
return b2w.getOrDefault(x,x);
}
}