Bird
Raised Fist0

Given existing bookings [(8, 10), (12, 14), (15, 17)], what will be the result of checking a new booking (10, 12) for conflict using the condition start_new < end_existing AND start_existing < end_new?

medium📝 Analysis Q4 of Q15
LLD - Design — Hotel Booking System
Given existing bookings [(8, 10), (12, 14), (15, 17)], what will be the result of checking a new booking (10, 12) for conflict using the condition start_new < end_existing AND start_existing < end_new?
AConflict with booking (12, 14)
BConflict with booking (8, 10)
CNo conflict, booking can be added
DConflict with bookings (8, 10) and (12, 14)
Step-by-Step Solution
Solution:
  1. Step 1: Analyze each existing booking

    Check overlap with (8,10): 10 < 10 is false, no overlap.
    Check overlap with (12,14): 10 < 14 is true, but 12 < 12 is false, no overlap.
    Check overlap with (15,17): 10 < 17 true, 15 < 12 false, no overlap.
  2. Step 2: Conclusion

    New booking (10,12) does not overlap with any existing booking.
  3. Final Answer:

    No conflict, booking can be added -> Option C
  4. Quick Check:

    Check if new booking starts exactly when previous ends [OK]
Quick Trick: Back-to-back bookings do not conflict [OK]
Common Mistakes:
MISTAKES
  • Assuming end time equals start time means overlap
  • Using < instead of <= causing false conflicts
  • Not checking all existing bookings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes