#105easyIntervals
Can Attend All Sessions
Time Limit: 2sMemory: 256MB
Problem
A quantitative analyst has a schedule of training sessions during the day. Determine whether they can attend all sessions without any time conflicts. Two sessions conflict if they overlap (sharing only an endpoint is fine — e.g., [1,5] and [5,10] don't conflict).
Input Format
- Line 1: integer
n(number of sessions). - Line 2:
2*nspace-separated integers as consecutive start-end pairs (empty if n=0).
Output Format
Print true if all sessions can be attended, false otherwise.
Examples
Example 1
Input(Line 1: integer n (number of sessions).)
3 0 30 5 10 15 20
Output
false
[0,30] overlaps with [5,10] and [15,20]. Cannot attend all.
Example 2
Input(Line 1: integer n (number of sessions).)
3 7 10 2 4 5 6
Output
true
Sorted: [2,4],[5,6],[7,10]. No overlaps.
Constraints
- •0 ≤ number of intervals ≤ 10^4
- •0 ≤ start < end ≤ 10^6
Loading interactive editor…