当前位置:网站首页>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);
*/
边栏推荐
- Station B, Mr. Liu Er - multiple logistic regression, structure 7
- Network protocol model
- Analysis report on development trends and investment planning of China's methanol industry from 2022 to 2028
- A complete collection of necessary learning websites for office programmers
- Detailed explanation of BF and KMP
- Sqlmap tutorial (III) practical skills II
- H3C firewall rbm+vrrp networking configuration
- 养了只小猫咪
- Auto. JS learning notes 17: basic listening events and UI simple click event operations
- VINS-Mono: A Robust and Versatile Monocular Visual-Inertial State Estimator
猜你喜欢
MIT6.s081-2020 Lab2 System Calls
Report on the competition status and investment decision recommendations of Guangxi hospital industry in China from 2022 to 2028
[web security] nodejs prototype chain pollution analysis
授予渔,从0开始搭建一个自己想要的网页
Web服务连接器:Servlet
假设检验学习笔记
【论文阅读】NFlowJS:基于鲁棒学习的合成负数据密集异常检测
(5) Explanation of yolo-v3 core source code (3)
MPLS test report
Database: ODBC remote access SQL Server2008 in oracel
随机推荐
Wib3.0 leapfrogging, in leapfrogging (ง • ̀_•́) ง
查詢生產訂單中某個(些)工作中心對應的標准文本碼
Software test interview questions - Test Type
SQLMAP使用教程(三)实战技巧二
CoDeSys note 2: set coil and reset coil
J'ai un chaton.
[web security] nodejs prototype chain pollution analysis
Request forwarding and redirection
【LeetCode】Day96-第一个唯一字符&赎金信&字母异位词
查询生产订单中某个(些)工作中心对应的标准文本码
continue和break的区别与用法
【Postman】动态变量(也称Mock函数)
Query the standard text code corresponding to a work center (s) in the production order
多线程应用的测试与调试
IP day 16 VLAN MPLS configuration
Station B, Mr. Liu Er - multiple logistic regression, structure 7
【论文代码】SML部分代码阅读
MPLS test report
Bit operation rules
養了只小猫咪