Skip to content

731. My Calendar II #617

Answered by kovatz
mah-shamim asked this question in Q&A
Sep 27, 2024 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

We need to maintain two lists of bookings:

  1. Single Bookings: A list that keeps track of all events that are booked once.
  2. Double Bookings: A list that keeps track of all events that are double booked.

When a new event is requested, we need to check if it will cause a triple booking. To do that:

  • We first check if the new event overlaps with any of the intervals in the double bookings list. If it does, we cannot add the event because it would lead to a triple booking.
  • If there is no overlap with the double bookings, we then check the single bookings list and add the overlap of the new event with existing events to the double bookings list.

Finally, if the event passes both checks, we add …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@mah-shamim
Comment options

mah-shamim Sep 27, 2024
Maintainer Author

@kovatz
Comment options

kovatz Sep 27, 2024
Collaborator

Answer selected by mah-shamim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested medium Difficulty hacktoberfest-accepted hacktoberfest accepted
2 participants