732. My Calendar III Hard
1/**
2 * [732] My Calendar III
3 *
4 * A k-booking happens when k events have some non-empty intersection (i.e., there is some time that is common to all k events.)
5 * You are given some events [start, end), after each given event, return an integer k representing the maximum k-booking between all the previous events.
6 * Implement the MyCalendarThree class:
7 *
8 * MyCalendarThree() Initializes the object.
9 * int book(int start, int end) Returns an integer k representing the largest integer such that there exists a k-booking in the calendar.
10 *
11 *
12 * Example 1:
13 *
14 * Input
15 * ["MyCalendarThree", "book", "book", "book", "book", "book", "book"]
16 * [[], [10, 20], [50, 60], [10, 40], [5, 15], [5, 10], [25, 55]]
17 * Output
18 * [null, 1, 1, 2, 3, 3, 3]
19 * Explanation
20 * MyCalendarThree myCalendarThree = new MyCalendarThree();
21 * myCalendarThree.book(10, 20); // return 1, The first event can be booked and is disjoint, so the maximum k-booking is a 1-booking.
22 * myCalendarThree.book(50, 60); // return 1, The second event can be booked and is disjoint, so the maximum k-booking is a 1-booking.
23 * myCalendarThree.book(10, 40); // return 2, The third event [10, 40) intersects the first event, and the maximum k-booking is a 2-booking.
24 * myCalendarThree.book(5, 15); // return 3, The remaining events cause the maximum K-booking to be only a 3-booking.
25 * myCalendarThree.book(5, 10); // return 3
26 * myCalendarThree.book(25, 55); // return 3
27 *
28 *
29 * Constraints:
30 *
31 * 0 <= start < end <= 10^9
32 * At most 400 calls will be made to book.
33 *
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/my-calendar-iii/
38// discuss: https://leetcode.com/problems/my-calendar-iii/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42struct MyCalendarThree {
43 vec![]
44 }
45
46
47/**
48 * `&self` means the method takes an immutable reference.
49 * If you need a mutable reference, change it to `&mut self` instead.
50 */
51impl MyCalendarThree {
52
53 fn new() -> Self {
54
55 }
56
57 fn book(&self, start: i32, end: i32) -> i32 {
58
59 }
60}
61
62/**
63 * Your MyCalendarThree object will be instantiated and called as such:
64 * let obj = MyCalendarThree::new();
65 * let ret_1: i32 = obj.book(start, end);
66 */
67
68// submission codes end
69
70#[cfg(test)]
71mod tests {
72 use super::*;
73
74 #[test]
75 fn test_732() {
76 }
77}
78
Back
© 2025 bowen.ge All Rights Reserved.