mapping
to store the remapping of blacklisted to whitelisted numbers.blacklist
array.blacklist
into two parts: blacklist1
with numbers less than n - len(blacklist)
and blacklist2
with the rest.whitelist
of all numbers in the range [n - len(blacklist), n)
that are not in blacklist2
.blacklist1
and map each number to a corresponding number in whitelist
using mapping
.pick()
is called, generate a random index in [0, n - len(blacklist))
.mapping
, return it; otherwise, return the mapped value from mapping
.