710. Random Pick with Blacklist 黑名单中的随机数(Hard)
1. 描述给定一个包含 [0,n) 中不重复整数的黑名单 blacklist ,写一个函数从 [0, n) 中返回一个不在 blacklist 中的随机整数。对它进行优化使其尽量少的调用Math.random()。You are given an integer n and an array of unique integers blacklist. Design an algorithm to pick a random integer in the range [0, n - 1] tha
原创
2021-08-29 11:06:54 ·
153 阅读 ·
0 评论