You are given an array events where events[i] = [startDay_i, endDay_i]. Event i runs on every day from startDay_i to endDay_i inclusive, and you can attend it on any one of those days. You can attend at most one event per day. Return the maximum number of events you can attend.
You are given an array events where events[i] = [startDay_i, endDay_i]. Event i runs on every day from startDay_i to endDay_i inclusive, and you can attend it on any one of those days. You can 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
Constraints:
1≤events.length≤105
events[i].length=2
1≤startDayi≤endDayi≤105
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"events":[[1,2],[2,3],[3,4]]}
3 events. Each day you may attend one event that is running that day. Greedy rule: on each day, attend the open event that ends soonest.