leetcode729. My Calendar I
来源:互联网 发布:抹茶美妆软件 编辑:程序博客网 时间:2024/04/30 05:05
设一个字典记录所有被预定的页面,然后就是判断区间相交了
当发生以下两种情况之一时认为区间相交
1、起点小于左端点且终点大于左端点
2、起点大于等于左端点且起点小于右端点
代码如下
class MyCalendar(object): dic = {} def __init__(self): self.dic = {} def book(self, start, end): """ :type start: int :type end: int :rtype: bool """ ok = True; for left in self.dic: right = self.dic[left] if start < left and left < end: ok = False if left <= start and start < right: ok = False; if ok: self.dic[start] = end return ok# Your MyCalendar object will be instantiated and called as such:# obj = MyCalendar()# param_1 = obj.book(start,end)
阅读全文
1 0
- leetcode729. My Calendar I
- Leetcode_729. My Calendar I
- 729. My Calendar I
- 729. My Calendar I
- leetCode-My Calendar I
- 29. My Calendar I
- LeetCode.729 My Calendar I
- LeetCode | 729. My Calendar I
- leetcode: 729. My Calendar I,731. My Calendar II
- LEETCODE: 729. My Calendar I & 731. My Calendar II
- 729. My Calendar I && 731. My Calendar II && 732. My Calendar III
- LWC 59:729. My Calendar I
- My Calendar I问题及解法
- My Calendar
- 731. My Calendar II
- 732. My Calendar III
- 732. My Calendar III
- leetCode-My Calendar II
- 秒杀系统设计
- Eclipse装AmaterasUML插件
- HDU2036
- windows主机与虚拟机Linux共享文件夹
- ReactNative安卓端的打包发布
- leetcode729. My Calendar I
- 简单电路
- Keras-3 Keras With Otto Group
- jenkins的具体搭建和使用—使用tomcat容器
- 【练习题】构造方法 编写Java程序,模拟简单的计算器。
- Linux中GDB调试
- 三种继承、多态-虚函数
- 分享一篇百度云续命的大法
- struts2的初学