当前位置:网站首页>LeetCode 732. 我的日程安排表 III
LeetCode 732. 我的日程安排表 III
2022-07-06 06:02:00 【Sasakihaise_】
【离散化的差分数组】
class MyCalendarThree {
// 离散差分数组 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);
*/
边栏推荐
猜你喜欢
IDEA 新UI使用
[web security] nodejs prototype chain pollution analysis
Web service connector: Servlet
Report on market depth analysis and future trend prediction of China's arsenic trioxide industry from 2022 to 2028
LTE CSFB process
Practice sharing: how to safely and quickly migrate from CentOS to openeuler
关于 PHP 启动 MongoDb 找不到指定模块问题
功能安全之故障(fault),错误(error),失效(failure)
Clear floating mode
Investment strategy discussion and market scale prediction report of China's solid state high power amplifier industry from 2022 to 2028
随机推荐
功能安全之故障(fault),错误(error),失效(failure)
Introduction to promql of # yyds dry goods inventory # Prometheus
Network protocol model
Station B Liu Erden softmx classifier and MNIST implementation -structure 9
About PHP startup, mongodb cannot find the specified module
Novice entry SCM must understand those things
Linux regularly backs up MySQL database
The difference and usage between continue and break
GTSAM中李群的運用
Implementation of linked list in address book management system
Demander le Code de texte standard correspondant à un centre de travail dans l'ordre de production
[course notes] Compilation Principle
[Thesis code] SML part code reading
Request forwarding and redirection
【Postman】Collections配置运行过程
Software test interview questions - Test Type
IDEA 新UI使用
Clock in during winter vacation
H3C S5820V2_ Upgrade method after stacking IRF2 of 5830v2 switch
Seven imperceptible truths in software testing