You are running a TV network that has the rights to transmit the olympic games. The network is going to create several channels that transmit events of the games continuously. Few rules have been established for these new channels:
- Each event cannot be transmitted on more than one channel
- Any part of an event may be included in the scheduled programming, even if the beginning and/or the end of it are excluded, but at most one interval of the event can be shown
- Each channel must have a continuous transmission
You will be given the schedule of the olympics in 2 int[]s startingTime and endingTime, with the ith element of startingTime and endingTime representing the starting and ending time of the ith scheduled event in a special time unit (each interval contains both endpoints, see examples for further clarification). The duration of the games is exactly totalUnits of this time units, which means that the transmition of all the created channels must start at time 0 and end at time totalUnits. Return the maximum number of channels that can be created while satisfying these network policies.
|