当前位置:网站首页>2022.6.26-----leetcode. seven hundred and ten
2022.6.26-----leetcode. seven hundred and ten
2022-06-27 08:25:00 【Lu 727】
// take [0,n-m-1] Number of blacklists and [n−m,n-1] The white name singular of , Random return [0,n-m-1] Number in Li
Map<Integer, Integer> b2w;
Random random;
int bound;
public Solution(int n, int[] blacklist) {
b2w = new HashMap<Integer, Integer>();
random = new Random();
int m = blacklist.length;
bound = n - m;
Set<Integer> black = new HashSet<Integer>();
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);
}边栏推荐
- Lvgl usage demo and instructions 2
- 【云原生】2.3 Kubernetes 核心实战(上)
- Mapping of Taobao virtual product store opening tutorial
- vim 从嫌弃到依赖(19)——替换
- Helix QAC is updated to 2022.1 and will continue to provide high standard compliance coverage
- [c++ primer notes] Chapter 4 expression
- 即构「畅直播」,全链路升级的一站式直播服务
- 【批处理DOS-CMD命令-汇总和小结】-输出/显示命令——echo
- JVM层次上的对象的创建过程和内存布局
- 【11. 二维差分】
猜你喜欢

JVM层次上的对象的创建过程和内存布局

Helix QAC更新至2022.1版本,将持续提供高标准合规覆盖率

Redis五种基本类型

"Short video" Linxia fire rescue detachment carries out fire safety training

lvgl 说明3关于lvgl guider的使用

L'enquête en aveugle a montré que les femmes étaient meilleures que les hommes.

win10-如何管理开机启动项?

Programming life - what do you think of the 35 year old bottleneck of programmers?

Reference | upgrade win11 mobile hotspot can not be opened or connected

100%弄明白5种IO模型
随机推荐
Associated GIS: all roads lead to ue5 City
八大误区,逐个击破(终篇):云难以扩展、定制性差,还会让管理员失去控制权?
ACM course term summary
【批处理DOS-CMD命令-汇总和小结】-将文件夹映射成虚拟磁盘——subst
05 观察者(Observer)模式
爬一个网页的所有导师信息
招聘需求 视觉工程师
Etcd教程 — 第五章 Etcd之etcdctl的使用
win10-如何管理开机启动项?
洛谷刷题心得记录
100% understanding of 5 IO models
野風藥業IPO被終止:曾擬募資5.4億 實控人俞蘠曾進行P2P投資
准备好迁移上云了?请收下这份迁移步骤清单
All tutor information on one page
ArrayList和LinkedList的区别
LVGL GUI GUIDER移植代码到STM32
【批处理DOS-CMD命令-汇总和小结】-输出/显示命令——echo
lvgl 说明3关于lvgl guider的使用
MATLAB小技巧(18)矩阵分析--熵权法
orthofinder直系同源蛋白分析及结果处理