Dsa
Binary Search
Easy
Book Reservation System
In a theater, you have a fixed number of seats which can be reserved. Given the list of seat numbers that have already been reserved, determine if a requested seat number is available for reservation.
Input:
- The first line contains the integer R (1 ≤ R ≤ 10^5), the number of reserved seats.
- The second line contains R space-separated integers representing the reserved seat numbers.
- The third line contains an integer S (1 ≤ S ≤ 10^6), the requested seat number for reservation.
Output:
- Print 'Available' if the seat number is not reserved, otherwise print 'Unavailable'.
Example:
Input:
5
10 15 20 30 5
12
Output:
Available
Key concepts
binary_searchconditionalsstrings
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now