当前位置:网站首页>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);
*/
边栏推荐
- 「 WEB测试工程师 」岗位一面总结
- 模拟卷Leetcode【普通】1447. 最简分数
- (中)苹果有开源,但又怎样呢?
- LeetCode 729. 我的日程安排表 I
- 进程和线程的理解
- 模拟卷Leetcode【普通】1219. 黄金矿工
- QT: the program input point xxxxx cannot be located in the dynamic link library.
- [C language] string left rotation
- Postman核心功能解析-参数化和测试报告
- Simulation volume leetcode [general] 1062 Longest repeating substring
猜你喜欢
职场进阶指南:大厂人必看书籍推荐
Summary of anomaly detection methods
Detailed explanation of P problem, NP problem, NPC problem and NP hard problem
Black cat takes you to learn EMMC Protocol Part 10: EMMC read and write operation details (read & write)
MySQL之数据类型
E - 食物链
Mise en œuvre d’une fonction complexe d’ajout, de suppression et de modification basée sur jeecg - boot
黑猫带你学UFS协议第4篇:UFS协议栈详解
Pat (Grade B) 2022 summer exam
全程实现单点登录功能和请求被取消报错“cancelToken“ of undefined的解决方法
随机推荐
【MQTT从入门到提高系列 | 01】从0到1快速搭建MQTT测试环境
An article was uncovered to test the truth of outsourcing companies
JDBC Requset 对应内容及功能介绍
Black cat takes you to learn UFS protocol Chapter 4: detailed explanation of UFS protocol stack
浅谈专项测试之弱网络测试
数据库隔离级别
Delete the variables added to watch1 in keil MDK
Customize the gateway filter factory on the specified route
模拟卷Leetcode【普通】1296. 划分数组为连续数字的集合
LeetCode 731. 我的日程安排表 II
MySQL is sorted alphabetically
Web界面元素的测试
Left matching principle of joint index
Thoughts on data security (Reprint)
[postman] collections - run the imported data file of the configuration
Convert the array selected by El tree into an array object
Cannot create poolableconnectionfactory (could not create connection to database server. error
Detailed explanation of P problem, NP problem, NPC problem and NP hard problem
Simulation volume leetcode [general] 1061 Arrange the smallest equivalent strings in dictionary order
Understanding of processes and threads