3440. Reschedule Meetings for Maximum Free Time II Medium
1/**
2 * [3440] Reschedule Meetings for Maximum Free Time II
3 *
4 * You are given an integer eventTime denoting the duration of an event. You are also given two integer arrays startTime and endTime, each of length n.
5 * These represent the start and end times of n non-overlapping meetings that occur during the event between time t = 0 and time t = eventTime, where the i^th meeting occurs during the time [startTime[i], endTime[i]].
6 * You can reschedule at most one meeting by moving its start time while maintaining the same duration, such that the meetings remain non-overlapping, to maximize the longest continuous period of free time during the event.
7 * Return the maximum amount of free time possible after rearranging the meetings.
8 * Note that the meetings can not be rescheduled to a time outside the event and they should remain non-overlapping.
9 * Note: In this version, it is valid for the relative ordering of the meetings to change after rescheduling one meeting.
10 *
11 * <strong class="example">Example 1:
12 * <div class="example-block">
13 * Input: <span class="example-io">eventTime = 5, startTime = [1,3], endTime = [2,5]</span>
14 * Output: <span class="example-io">2</span>
15 * Explanation:
16 * <img alt="" src="https://assets.leetcode.com/uploads/2024/12/22/example0_rescheduled.png" style="width: 375px; height: 123px;" />
17 * Reschedule the meeting at [1, 2] to [2, 3], leaving no meetings during the time [0, 2].
18 * </div>
19 * <strong class="example">Example 2:
20 * <div class="example-block">
21 * Input: <span class="example-io">eventTime = 10, startTime = [0,7,9], endTime = [1,8,10]</span>
22 * Output: <span class="example-io">7</span>
23 * Explanation:
24 * <img alt="" src="https://assets.leetcode.com/uploads/2024/12/22/rescheduled_example0.png" style="width: 375px; height: 125px;" />
25 * Reschedule the meeting at [0, 1] to [8, 9], leaving no meetings during the time [0, 7].
26 * </div>
27 * <strong class="example">Example 3:
28 * <div class="example-block">
29 * Input: <span class="example-io">eventTime = 10, startTime = [0,3,7,9], endTime = [1,4,8,10]</span>
30 * Output: 6
31 * Explanation:
32 * <img alt="" src="https://assets.leetcode.com/uploads/2025/01/28/image3.png" style="width: 375px; height: 125px;" />
33 * Reschedule the meeting at [3, 4] to [8, 9], leaving no meetings during the time [1, 7].
34 * </div>
35 * <strong class="example">Example 4:
36 * <div class="example-block">
37 * Input: <span class="example-io">eventTime = 5, startTime = [0,1,2,3,4], endTime = [1,2,3,4,5]</span>
38 * Output: <span class="example-io">0</span>
39 * Explanation:
40 * There is no time during the event not occupied by meetings.
41 * </div>
42 *
43 * Constraints:
44 *
45 * 1 <= eventTime <= 10^9
46 * n == startTime.length == endTime.length
47 * 2 <= n <= 10^5
48 * 0 <= startTime[i] < endTime[i] <= eventTime
49 * endTime[i] <= startTime[i + 1] where i lies in the range [0, n - 2].
50 *
51 */
52pub struct Solution {}
53
54// problem: https://leetcode.com/problems/reschedule-meetings-for-maximum-free-time-ii/
55// discuss: https://leetcode.com/problems/reschedule-meetings-for-maximum-free-time-ii/discuss/?currentPage=1&orderBy=most_votes&query=
56
57// submission codes start here
58
59impl Solution {
60 pub fn max_free_time(event_time: i32, start_time: Vec<i32>, end_time: Vec<i32>) -> i32 {
61 0
62 }
63}
64
65// submission codes end
66
67#[cfg(test)]
68mod tests {
69 use super::*;
70
71 #[test]
72 fn test_3440() {
73 }
74}
75
Back
© 2025 bowen.ge All Rights Reserved.