#K73987. Appointment Scheduling
Appointment Scheduling
Appointment Scheduling
You are given a list of existing appointments and a new appointment, each represented as a pair of times in 24-hour integer format. Your task is to determine whether the new appointment can be scheduled without overlapping any of the existing ones.
Two appointments are considered non-overlapping if the new appointment ends exactly when an existing appointment starts, or starts exactly when an existing appointment ends. Otherwise, they are considered overlapping. Time is represented in a 24-hour HHMM format (e.g., 900 for 9:00 AM and 1030 for 10:30 AM).
Mathematical Condition: Let an existing appointment be represented by \( (s, e) \) and the new appointment by \( (s_n, e_n) \). The new appointment does not overlap with an existing appointment if:
\( e_n \leq s \) or \( s_n \geq e \)
inputFormat
The first line of input contains an integer n, representing the number of existing appointments. Each of the following n lines contains two integers representing the start and end times of an existing appointment. The next line contains two integers representing the start and end times of the new appointment.
outputFormat
Output a single line containing 'True' if the new appointment can be scheduled without overlapping any existing appointment, otherwise output 'False'.## sample
3
900 1030
1200 1300
1400 1500
1030 1230
True
</p>