0
0
LLDsystem_design~10 mins

Booking conflict resolution in LLD - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to check if two bookings overlap.

LLD
def is_conflict(booking1, booking2):
    return booking1.end_time [1] booking2.start_time
Drag options to blanks, or click blank then click option'
A<=
B>
C==
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<=' causes missing conflicts when bookings overlap.
2fill in blank
medium

Complete the code to add a booking only if no conflicts exist.

LLD
def add_booking(bookings, new_booking):
    for b in bookings:
        if is_conflict(b, new_booking):
            return False
    bookings.append([1])
    return True
Drag options to blanks, or click blank then click option'
Anew_booking
Bb
Cbookings
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Appending an existing booking instead of the new one.
3fill in blank
hard

Fix the error in the conflict check to correctly detect overlapping bookings.

LLD
def is_conflict(booking1, booking2):
    return booking1.start_time [1] booking2.end_time and booking1.end_time [2] booking2.start_time
Drag options to blanks, or click blank then click option'
A<
B>
C<=
D>=
Attempts:
3 left
💡 Hint
Common Mistakes
Using <= or >= causes incorrect overlap detection.
4fill in blank
hard

Fill both blanks to create a function that returns all conflicting bookings for a new booking.

LLD
def find_conflicts(bookings, new_booking):
    conflicts = []
    for b in bookings:
        if b.start_time [1] new_booking.end_time and b.end_time [2] new_booking.start_time:
            conflicts.append(b)
    return conflicts
Drag options to blanks, or click blank then click option'
A<
B>
C<=
D>=
Attempts:
3 left
💡 Hint
Common Mistakes
Using <= or >= causes missing some conflicts.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps booking IDs to their durations for bookings longer than 1 hour.

LLD
durations = {b.id: (b.end_time - b.start_time).total_seconds() / 3600 for b in bookings if (b.end_time - b.start_time) [1] [2] and b.id [3] None}
Drag options to blanks, or click blank then click option'
A>
B1
C!=
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' for duration check.
Checking ID equality instead of inequality.