当前位置:网站首页>LeetCode 732. My schedule III
LeetCode 732. My schedule III
2022-07-06 06:23:00 【Sasakihaise_】
【 Discrete difference array 】
class MyCalendarThree {
// Discrete difference array 1:37
Map<Integer, Integer> map = new TreeMap();
public MyCalendarThree() {
}
public int book(int start, int end) {
map.put(start, map.getOrDefault(start, 0) + 1);
map.put(end, map.getOrDefault(end, 0) - 1);
int sum = 0, ans = 0;
for (var e: map.keySet()) {
sum += map.get(e);
ans = Math.max(sum, ans);
}
return ans;
}
}
/**
* Your MyCalendarThree object will be instantiated and called as such:
* MyCalendarThree obj = new MyCalendarThree();
* int param_1 = obj.book(start,end);
*/
边栏推荐
- 模拟卷Leetcode【普通】1296. 划分数组为连续数字的集合
- JWT-JSON WEB TOKEN
- LeetCode 1200. 最小绝对差
- 基于JEECG-BOOT制作“左树右表”交互页面
- QT: the program input point xxxxx cannot be located in the dynamic link library.
- 还在为如何编写Web自动化测试用例而烦恼嘛?资深测试工程师手把手教你Selenium 测试用例编写
- 模拟卷Leetcode【普通】1414. 和为 K 的最少斐波那契数字数目
- [postman] the monitors monitoring API can run periodically
- Black cat takes you to learn UFS Protocol Part 8: UFS initialization (boot operation)
- 黑猫带你学UFS协议第4篇:UFS协议栈详解
猜你喜欢
随机推荐
Qt:无法定位程序输入点XXXXX于动态链接库。
Remember the implementation of a relatively complex addition, deletion and modification function based on jeecg-boot
Redis core technology and basic architecture of actual combat: what does a key value database contain?
Simulation volume leetcode [general] 1091 The shortest path in binary matrix
在uni-app中使用腾讯视频插件播放视频
[postman] dynamic variable (also known as mock function)
黑猫带你学UFS协议第8篇:UFS初始化详解(Boot Operation)
The latest 2022 review of "graph classification research"
MFC dynamically creates dialog boxes and changes the size and position of controls
测试周期被压缩?教你9个方法去应对
G - Supermarket
Mise en œuvre d’une fonction complexe d’ajout, de suppression et de modification basée sur jeecg - boot
Simulation volume leetcode [general] 1249 Remove invalid parentheses
模拟卷Leetcode【普通】1414. 和为 K 的最少斐波那契数字数目
私人云盘部署
模拟卷Leetcode【普通】1249. 移除无效的括号
数据库-当前读与快照读
还在为如何编写Web自动化测试用例而烦恼嘛?资深测试工程师手把手教你Selenium 测试用例编写
【MQTT从入门到提高系列 | 01】从0到1快速搭建MQTT测试环境
Simulation volume leetcode [general] 1447 Simplest fraction