CT033

No-Overlap Picnic Booking

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The park host accepts as many non-overlapping picnic reservations as possible; guests leaving at a time may be followed by one arriving then. Task: Select the maximum number of compatible half-open intervals [start,end). Input format: n then n lines start end. Output format: Print maximum booking count. Constraints: 1 <= n <= 200000; 0 <= start < end <= 10^9

Example 1:

Input: 5 1 3 2 5 4 7 6 9 8 10
Output: 3

Example 2:

Input: 1 0 1
Output: 1

Example 3:

Input: 4 0 2 2 4 4 6 6 8
Output: 4

Constraints:

1 <= n <= 200000; 0 <= start < end <= 10^9

Tags:

greedy interval-scheduling
Loading...
Test Cases:No test cases
No test cases available.
No-Overlap Picnic Booking - MEDIUM Coding Problem | CodeTikki