当前位置:网站首页>Force buckle 729 My schedule I
Force buckle 729 My schedule I
2022-07-05 19:28:00 【Ruthless young Fisherman】
subject
Achieve one MyCalendar Class to store your schedule . If the schedule to be added does not cause Repeat Booking , You can store this new schedule .
When there is some time overlap between the two schedules ( For example, both schedules are in the same time ), It will produce Repeat Booking .
The schedule can use a pair of integers start and end Express , The time here is a half open interval , namely [start, end), The set of real Numbers x For the range of , start <= x < end .
Realization MyCalendar class :
MyCalendar() Initialize calendar object .
boolean book(int start, int end) If the schedule can be successfully added to the calendar without causing duplicate bookings , return true . otherwise , return false And don't add the schedule to the calendar .
Example
Input :
[“MyCalendar”, “book”, “book”, “book”]
[[], [10, 20], [15, 25], [20, 30]]
Output :
[null, true, false, true]
explain :
MyCalendar myCalendar = new MyCalendar();
myCalendar.book(10, 20); // return True
myCalendar.book(15, 25); // return False , This schedule cannot be added to the calendar , Because of time 15 Has been booked by another schedule .
myCalendar.book(20, 30); // return True , This schedule can be added to the calendar , Because the first schedule is booked at less than each time 20 , And does not include time 20 .
source : Power button (LeetCode)
link :https://leetcode.cn/problems/my-calendar-i
Copyright belongs to the network . For commercial reprint, please contact the official authority , Non-commercial reprint please indicate the source .
Method 1: simulation

Java Realization
class MyCalendar {
List<int[]> list;
public MyCalendar() {
list = new ArrayList<>();
}
public boolean book(int start, int end) {
end--; //
for (int[] var : list) {
int l = var[0], r = var[1];
if (start > r || end < l) continue;
return false;
}
list.add(new int[]{
start, end});
return true;
}
}

边栏推荐
- Cf:b. almost Terry matrix [symmetry + finding rules + structure + I am structural garbage]
- Realizing deep learning framework from zero -- LSTM from theory to practice [practice]
- JMeter 常用的几种断言方法,你会了吗?
- Mysql如何对json数据进行查询及修改
- Reptile exercises (II)
- 面试官:Redis中集合数据类型的内部实现方式是什么?
- Fuzor 2020软件安装包下载及安装教程
- IFD-x 微型红外成像仪(模块)关于温度测量和成像精度的关系
- Go deep into the underlying C source code and explain the core design principles of redis
- HiEngine:可媲美本地的云原生内存数据库引擎
猜你喜欢

Millimeter wave radar human body sensor, intelligent perception of static presence, human presence detection application

Blue sky drawing bed Apple quick instructions

Fuzor 2020 software installation package download and installation tutorial

Xaas trap: all things serve (possible) is not what it really needs

数学分析_笔记_第9章:曲线积分与曲面积分

基于FPGA的超声波测距

Ten years at sea: old and new relay, dark horse rising

开源 SPL 消灭数以万计的数据库中间表

全网最全的低代码/无代码平台盘点:简道云、伙伴云、明道云、轻流、速融云、集简云、Treelab、钉钉·宜搭、腾讯云·微搭、智能云·爱速搭、百数云

14、用户、组和权限(14)
随机推荐
5 years of experience, 27 days of Android programmer interview, 2022 programmer advanced classic
XaaS 陷阱:万物皆服务(可能)并不是IT真正需要的东西
Reinforcement learning - learning notes 4 | actor critical
Which securities company is better and which platform is safer for mobile account opening
Get wechat avatar and nickname with uniapp
Teach you to deal with JS reverse picture camouflage hand in hand
毫米波雷达人体感应器,智能感知静止存在,人体存在检测应用
Debezium系列之:解析默认值字符集
如何实现游戏中的在线计时器和离线计时器
C# 语言的高级应用
Reptile exercises (II)
Notion 类生产力工具如何选择?Notion 、FlowUs 、Wolai 对比评测
关于 Notion-Like 工具的反思和畅想
How to convert word into PDF? Word to PDF simple way to share!
C#应用程序界面开发基础——窗体控制(5)——分组类控件
JAD installation, configuration and integration idea
建议收藏,我的腾讯Android面试经历分享
How about testing outsourcing companies?
PHP利用ueditor实现上传图片添加水印
webuploader文件上传 拖拽上传 进度监听 类型控制 上传结果监听控件