Bird
0
0

If a booking system uses a naive list to store bookings, what is the time complexity to check conflicts for a new booking among N existing bookings?

medium📝 Analysis Q5 of 15
LLD - Design — Hotel Booking System
If a booking system uses a naive list to store bookings, what is the time complexity to check conflicts for a new booking among N existing bookings?
AO(N)
BO(log N)
CO(1)
DO(N^2)
Step-by-Step Solution
Solution:
  1. Step 1: Understand naive list approach

    Each new booking must be checked against all existing bookings.
  2. Step 2: Calculate time complexity

    Checking all N bookings means O(N) time per conflict check.
  3. Final Answer:

    O(N) -> Option A
  4. Quick Check:

    Naive conflict check = linear time O(N) [OK]
Quick Trick: Naive conflict check scans all bookings linearly [OK]
Common Mistakes:
  • Assuming logarithmic time without indexing
  • Confusing O(1) with constant time

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes