1353. Maximum Number of Events That Can Be Attended Medium

@problem@discussion
#Array#Greedy#Heap (Priority Queue)



1/**
2 * [1353] Maximum Number of Events That Can Be Attended
3 *
4 * You are given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and ends at endDayi.
5 * You can attend an event i at any day d where startTimei <= d <= endTimei. You can only attend one event at any time d.
6 * Return the maximum number of events you can attend.
7 *  
8 * Example 1:
9 * <img alt="" src="https://assets.leetcode.com/uploads/2020/02/05/e1.png" style="width: 400px; height: 267px;" />
10 * Input: events = [[1,2],[2,3],[3,4]]
11 * Output: 3
12 * Explanation: You can attend all the three events.
13 * One way to attend them all is as shown.
14 * Attend the first event on day 1.
15 * Attend the second event on day 2.
16 * Attend the third event on day 3.
17 * 
18 * Example 2:
19 * 
20 * Input: events= [[1,2],[2,3],[3,4],[1,2]]
21 * Output: 4
22 * 
23 *  
24 * Constraints:
25 * 
26 * 	1 <= events.length <= 10^5
27 * 	events[i].length == 2
28 * 	1 <= startDayi <= endDayi <= 10^5
29 * 
30 */
31pub struct Solution {}
32
33// problem: https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended/
34// discuss: https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended/discuss/?currentPage=1&orderBy=most_votes&query=
35
36// submission codes start here
37
38impl Solution {
39    pub fn max_events(events: Vec<Vec<i32>>) -> i32 {
40        0
41    }
42}
43
44// submission codes end
45
46#[cfg(test)]
47mod tests {
48    use super::*;
49
50    #[test]
51    fn test_1353() {
52    }
53}
54


Back
© 2025 bowen.ge All Rights Reserved.