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-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>实现一个 <code>MyCalendar</code> 类来存放你的日程安排。如果要添加的时间内不会导致三重预订时,则可以存储这个新的日程安排。</p>\n\n<p><code>MyCalendar</code> 有一个 <code>book(int start, int end)</code>方法。它意味着在 <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>当三个日程安排有一些时间上的交叉时(例如三个日程安排都在同一时间内),就会产生三重预订。</p>\n\n<p>每次调用 <code>MyCalendar.book</code>方法时,如果可以将日程安排成功添加到日历中而不会导致三重预订,返回 <code>true</code>。否则,返回 <code>false</code> 并且不要将该日程安排添加到日历中。</p>\n\n<p>请按照以下步骤调用<code>MyCalendar</code> 类: <code>MyCalendar cal = new MyCalendar();</code> <code>MyCalendar.book(start, end)</code></p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例:</strong></p>\n\n<pre>MyCalendar();\nMyCalendar.book(10, 20); // returns true\nMyCalendar.book(50, 60); // returns true\nMyCalendar.book(10, 40); // returns true\nMyCalendar.book(5, 15); // returns false\nMyCalendar.book(5, 10); // returns true\nMyCalendar.book(25, 55); // returns true\n<strong>解释:</strong> \n前两个日程安排可以添加至日历中。 第三个日程安排会导致双重预订,但可以添加至日历中。\n第四个日程安排活动5,15不能添加至日历中因为它会导致三重预订。\n第五个日程安排5,10可以添加至日历中因为它未使用已经双重预订的时间10。\n第六个日程安排25,55可以添加至日历中因为时间 [25,40] 将和第三个日程安排双重预订;\n时间 [40,50] 将单独预订,时间 [50,55将和第二个日程安排双重预订。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li>每个测试用例,调用&nbsp;<code>MyCalendar.book</code>&nbsp;函数最多不超过&nbsp;<code>1000</code>次。</li>\n\t<li>调用函数&nbsp;<code>MyCalendar.book(start, end)</code>时,&nbsp;<code>start</code> 和&nbsp;<code>end</code> 的取值范围为&nbsp;<code>[0, 10^9]</code>。</li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 104,
"likes": 108,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[{\"title\": \"My Calendar I\", \"titleSlug\": \"my-calendar-i\", \"difficulty\": \"Medium\", \"translatedTitle\": \"\\u6211\\u7684\\u65e5\\u7a0b\\u5b89\\u6392\\u8868 I\"}, {\"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\": \"5.2K\", \"totalSubmission\": \"10.1K\", \"totalAcceptedRaw\": 5150, \"totalSubmissionRaw\": 10142, \"acRate\": \"50.8%\"}",
"stats": "{\"totalAccepted\": \"5.4K\", \"totalSubmission\": \"10.6K\", \"totalAcceptedRaw\": 5404, \"totalSubmissionRaw\": 10626, \"acRate\": \"50.9%\"}",
"hints": [
"Store two sorted lists of intervals: one list will be all times that are at least single booked, and another list will be all times that are definitely double booked. If none of the double bookings conflict, then the booking will succeed, and you should update your single and double bookings accordingly."
],