Belvedere Trading tracks candidate trade windows during the day. Given a list of time intervals, select the maximum number of non-overlapping windows that can be executed.
Write a function that returns the largest possible number of intervals such that no two selected intervals overlap. Two intervals a and b are non-overlapping if the end of one is less than or equal to the start of the other.
intervals, a list of pairs [start, end] where start and end are integersExample 1
Input: intervals = [[1,3],[2,4],[3,5],[0,2]]
Output: 2
Explanation: One optimal selection is [[0,2],[2,4]] or [[1,3],[3,5]].
Example 2
Input: intervals = [[1,2],[2,3],[3,4],[1,3]]
Output: 3
Explanation: Select [[1,2],[2,3],[3,4]]. Touching endpoints are allowed.
1 <= len(intervals) <= 10^50 <= start <= end <= 10^9