Dsa
Intervals
Medium
Class Time Slot Checker
You are assigned to create a system that checks whether a new class can fit into existing class schedules without overlapping. Given a set of existing classes and a new class time slot, your task is to determine if the new class can be scheduled without any conflict. Each time slot is represented as a pair of integers, representing the start and end times. You will read the existing classes and the new class, and output "CAN SCHEDULE" if the new class can fit, or "CANNOT SCHEDULE" otherwise.
Input Format:
- The first line contains an integer n (1 <= n <= 100).
- The next n lines each contain two integers representing the start and end times for each existing class.
- The last line contains two integers for the new class time slot.
Output Format:
- Print "CAN SCHEDULE" or "CANNOT SCHEDULE" based on the overlap check.
Example:
Input:
3
1 3
2 4
5 7
6 8
Output:
CANNOT SCHEDULE
Key concepts
intervalsbooleanoverlap
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now