#1353
Maximum Number of Events That Can Be Attended
expert · 1035 · lc medium +32 · verified · 38.9% accepted · 3,979 likes · top 18%
Description
You are given an array of events where events[i] = [startDayi, endDayi]. You can attend event i on any single day d with startDayi <= d <= endDayi, and you may attend at most one event per day. Return the maximum number of events you can attend.
Example 1:
Input: events = [[1,2],[2,3],[3,4]]
Output: 3
Explanation: You can attend all the three events.
One way to attend them all is as shown.
Attend the first event on day 1.
Attend the second event on day 2.
Attend the third event on day 3.
Example 2:
Input: events= [[1,2],[2,3],[3,4],[1,2]]
Output: 4
Code
1
2
3