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