events[i] = [start, end] means event i is on every day from start to end, inclusive. To count an event as visited, you only need to show up on any single day in that range.
You can visit at most one event per day. Return the largest number of different events you can visit.events=[[2, 4], [2, 2], [3, 3], [1, 4]] → 4
Day 1 goes to [1, 4], day 2 to [2, 2], day 3 to [3, 3] and day 4 to [2, 4], so all four fit.
events=[[5, 5], [5, 5], [5, 6]] → 2
Two events take place only on day 5, and the only other day, 6, goes to [5, 6]. One of the one-day events has to be skipped.
events=[[7, 9]] → 1
len(events) ≤ 10⁵events[i].length = 2start ≤ end ≤ 10⁵events=[[2, 4], [2, 2], [3, 3], [1, 4]]
4
Run checks the first 3 tests in your browser. Submit checks all 96 tests on the server, hidden ones included.