Maximum Number of Events That Can Be Attended
You are given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and ends at endDayi.
You can attend an event i on any day d where startDayi <= d <= endDayi. You can only attend one event at any day d.
Return the maximum number of events you can attend.
Example 1
Input
events = [[1,2],[2,3],[3,4]]Output
3You can attend all three events by attending them on days 1, 2, and 3 respectively.
Example 2
Input
events = [[1,2],[2,3],[3,4],[1,2]]Output
4The four events can be scheduled on distinct valid days, so all four can be attended.
Constraints
- 1 <= events.length <= 10^5
- events[i].length == 2
- 1 <= startDayi <= endDayi <= 10^5