Dsa
Binary Search
Medium
Product Availability Search
You run an online store that sells various products. Each product has a unique ID and they are stored in a sorted list. Given a list of product IDs and a product ID to check, determine if the product is in stock. Return 'Available' if it is; otherwise, return 'Not Available'.
Input format:
- The first line contains an integer n, the number of products.
- The second line contains n sorted integers (the product IDs).
- The third line contains the integer k, the product ID to check.
Output format:
- Print 'Available' or 'Not Available'.
Example:
Input:
5
1 3 5 7 9
5
Output:
Available
Key concepts
binary_searcharrayssorting
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