#C8774. Booking Availability Check
Booking Availability Check
Booking Availability Check
You are given a list of current room bookings along with a new booking request. Each booking contains the guest name, room type, check-in date, and check-out date. Your task is to determine whether the new booking can be accepted without any overlap with existing bookings of the same room type.
Two bookings are considered to overlap if the new booking's check‐in date is earlier than an existing booking's check‐out date and its check‐out date is later than the existing booking's check‐in date. Note that if the new booking's check-in date is equal to an existing booking's check-out date, there is no overlap.
Dates are provided in the format YYYY-MM-DD.
inputFormat
The input is given via standard input. The first line contains an integer n
, which represents the number of current bookings. The following n
lines each contain four space-separated values: guest
, room_type
, check_in
, and check_out
(all dates are in YYYY-MM-DD format). The next line contains the new booking details in the same format.
outputFormat
Output a single line to the standard output containing either True
if the booking can be accommodated, or False
otherwise.
2
Alice Deluxe 2023-10-01 2023-10-05
Bob Standard 2023-10-03 2023-10-08
David Standard 2023-10-09 2023-10-11
True