当前位置:网站首页>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);
*/
边栏推荐
- [C language] qsort function
- (中)苹果有开源,但又怎样呢?
- MFC 动态创建的对话框及改变控件的大小和位置
- Delete the variables added to watch1 in keil MDK
- sourceInsight中文乱码
- Simulation volume leetcode [general] 1414 The minimum number of Fibonacci numbers with a sum of K
- Career advancement Guide: recommended books for people in big factories
- Manhattan distance and Manhattan rectangle - print back font matrix
- [C language] string left rotation
- Isam2 and incrementalfixedlagsmooth instructions in gtsam
猜你喜欢

Caused by:org. gradle. api. internal. plugins . PluginApplicationException: Failed to apply plugin
![[postman] test script writing and assertion details](/img/65/6520fe78bb2b3ff99f16d09ea8c0d1.png)
[postman] test script writing and assertion details

【Postman】测试(Tests)脚本编写和断言详解

mysql按照首字母排序

Mise en œuvre d’une fonction complexe d’ajout, de suppression et de modification basée sur jeecg - boot

Construction and integration of Zipkin and sleuth for call chain monitoring

Career advancement Guide: recommended books for people in big factories

[no app push general test plan

基于JEECG-BOOT的list页面的地址栏参数传递
![[postman] the monitors monitoring API can run periodically](/img/9e/3f6150290b868fc1160b6b01d0857e.png)
[postman] the monitors monitoring API can run periodically
随机推荐
Is the test cycle compressed? Teach you 9 ways to deal with it
MFC on the conversion and display of long string unsigned char and CString
Properties file
Technology sharing | common interface protocol analysis
[postman] dynamic variable (also known as mock function)
MFC关于长字符串unsigned char与CString转换及显示问题
职场进阶指南:大厂人必看书籍推荐
D - How Many Answers Are Wrong
数据库-当前读与快照读
org.activiti.bpmn.exceptions.XMLException: cvc-complex-type.2.4.a: 发现了以元素 ‘outgoing‘ 开头的无效内容
模拟卷Leetcode【普通】1296. 划分数组为连续数字的集合
Isam2 operation process
[Tera term] black cat takes you to learn TTL script -- serial port automation skill in embedded development
Database isolation level
Simulation volume leetcode [general] 1143 Longest common subsequence
[C language] string left rotation
leetcode 24. 两两交换链表中的节点
Simulation volume leetcode [general] 1296 Divide an array into a set of consecutive numbers
还在为如何编写Web自动化测试用例而烦恼嘛?资深测试工程师手把手教你Selenium 测试用例编写
Simulation volume leetcode [general] 1061 Arrange the smallest equivalent strings in dictionary order