当前位置:网站首页>LeetCode 729. My schedule I
LeetCode 729. My schedule I
2022-07-06 06:23:00 【Sasakihaise_】

【 Ordered set 】 First, the range of the interval reaches 10^9, So it can't pass start + 1,end - 1 This kind of difference group indicates whether it has been covered . And because this is online inquiry ( Queries are dynamic , Not all intervals are inserted before querying ) Because it cannot be discretized . So consider TreeMap Carry out dynamic insertion and judgment of intervals .
Sort by left endpoint , For New Area , lookup <end( Be careful : here end It's open , So look for < He ) Maximum key, Judge value whether >start, If > Explain that the interval coincides , Otherwise, insert it .
distinguish :java in TreeMap Yes :floorKey(floorEntry),lowerKey(lowerEntry) The two methods , The difference is that the former contains equal to . Empathy ceilKey(highterKey) It's also .
class MyCalendar {
// Ordered set 1:24 1:26
TreeMap<Integer, Integer> map = new TreeMap();
public MyCalendar() {
}
public boolean book(int start, int end) {
Integer key = map.lowerKey(end);
if (key != null) {
if (map.get(key) > start) {
return false;
}
}
map.put(start, end);
return true;
}
}
/**
* Your MyCalendar object will be instantiated and called as such:
* MyCalendar obj = new MyCalendar();
* boolean param_1 = obj.book(start,end);
*/
边栏推荐
- ESP32 ESP-IDF看门狗TWDT
- Thoughts on data security (Reprint)
- Data type of MySQL
- 對數據安全的思考(轉載)
- 测试周期被压缩?教你9个方法去应对
- Redis core technology and basic architecture of actual combat: what does a key value database contain?
- (中)苹果有开源,但又怎样呢?
- 在uni-app中使用腾讯视频插件播放视频
- 模拟卷Leetcode【普通】1218. 最长定差子序列
- Simulation volume leetcode [general] 1314 Matrix area and
猜你喜欢

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower

Convert the array selected by El tree into an array object

MFC关于长字符串unsigned char与CString转换及显示问题

【无App Push 通用测试方案

调用链监控Zipkin、sleuth搭建与整合

Postman核心功能解析-参数化和测试报告

Technology sharing | common interface protocol analysis

Digital triangle model acwing 1015 Picking flowers

F - True Liars (种类并查集+DP)

10m25dcf484c8g (FPGA) amy-6m-0002 BGA GPS module
随机推荐
Black cat takes you to learn UFS protocol Chapter 4: detailed explanation of UFS protocol stack
win10无法操作(删除、剪切)文件
模拟卷Leetcode【普通】1405. 最长快乐字符串
Web界面元素的测试
PHP uses redis to implement distributed locks
模拟卷Leetcode【普通】1062. 最长重复子串
Set the print page style by modifying style
php使用redis实现分布式锁
【Tera Term】黑猫带你学TTL脚本——嵌入式开发中串口自动化神技能
二维码的前世今生 与 六大测试点梳理
【MQTT从入门到提高系列 | 01】从0到1快速搭建MQTT测试环境
黑猫带你学eMMC协议第10篇:eMMC读写操作详解(read & write)
模拟卷Leetcode【普通】1061. 按字典序排列最小的等效字符串
JWT-JSON WEB TOKEN
selenium源码通读·9 |DesiredCapabilities类分析
Black cat takes you to learn UFS Protocol Part 8: UFS initialization (boot operation)
黑猫带你学UFS协议第4篇:UFS协议栈详解
(中)苹果有开源,但又怎样呢?
The pit encountered by keil over the years
对数据安全的思考(转载)