1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-21 13:06:47 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-03-29 16:56:27 +08:00
parent e730aa6794
commit ad15da05aa
2517 changed files with 7358 additions and 7332 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>实现一个 <code>MyCalendar</code> 类来存放你的日程安排。如果要添加的日程安排不会造成 <strong>重复预订</strong> ,则可以存储这个新的日程安排。</p>\n\n<p>当两个日程安排有一些时间上的交叉时(例如两个日程安排都在同一时间内),就会产生 <strong>重复预订</strong> 。</p>\n\n<p>日程可以用一对整数 <code>start</code> 和 <code>end</code> 表示,这里的时间是半开区间,即 <code>[start, end)</code>, 实数&nbsp;<code>x</code> 的范围为, &nbsp;<code>start &lt;= x &lt; end</code> 。</p>\n\n<p>实现 <code>MyCalendar</code> 类:</p>\n\n<ul>\n\t<li><code>MyCalendar()</code> 初始化日历对象。</li>\n\t<li><code>boolean book(int start, int end)</code> 如果可以将日程安排成功添加到日历中而不会导致重复预订,返回 <code>true</code> 。否则,返回 <code>false</code>&nbsp;并且不要将该日程安排添加到日历中。</li>\n</ul>\n\n<p>&nbsp;</p>\n\n<p><strong>示例:</strong></p>\n\n<pre>\n<strong>输入:</strong>\n[\"MyCalendar\", \"book\", \"book\", \"book\"]\n[[], [10, 20], [15, 25], [20, 30]]\n<strong>输出:</strong>\n[null, true, false, true]\n\n<strong>解释:</strong>\nMyCalendar myCalendar = new MyCalendar();\nmyCalendar.book(10, 20); // return True\nmyCalendar.book(15, 25); // return False ,这个日程安排不能添加到日历中,因为时间 15 已经被另一个日程安排预订了。\nmyCalendar.book(20, 30); // return True ,这个日程安排可以添加到日历中,因为第一个日程安排预订的每个时间都小于 20 ,且不包含时间 20 。</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>0 &lt;= start &lt; end &lt;= 10<sup>9</sup></code></li>\n\t<li>每个测试用例,调用 <code>book</code> 方法的次数最多不超过 <code>1000</code> 次。</li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 113,
"likes": 114,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[{\"title\": \"My Calendar II\", \"titleSlug\": \"my-calendar-ii\", \"difficulty\": \"Medium\", \"translatedTitle\": \"\\u6211\\u7684\\u65e5\\u7a0b\\u5b89\\u6392\\u8868 II\"}, {\"title\": \"My Calendar III\", \"titleSlug\": \"my-calendar-iii\", \"difficulty\": \"Hard\", \"translatedTitle\": \"\\u6211\\u7684\\u65e5\\u7a0b\\u5b89\\u6392\\u8868 III\"}]",
@@ -149,7 +149,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"11.7K\", \"totalSubmission\": \"22.1K\", \"totalAcceptedRaw\": 11705, \"totalSubmissionRaw\": 22052, \"acRate\": \"53.1%\"}",
"stats": "{\"totalAccepted\": \"11.8K\", \"totalSubmission\": \"22.2K\", \"totalAcceptedRaw\": 11775, \"totalSubmissionRaw\": 22166, \"acRate\": \"53.1%\"}",
"hints": [
"Store the events as a sorted list of intervals. If none of the events conflict, then the new event can be added."
],