Dsa
Binary Search
Easy
Finding the Duplicate Book
You manage a library and want to find out if any book has been accidentally entered more than once in your database. The database is represented as an array of book IDs. Your task is to identify if there is any duplicate book ID in the database using binary search methods.
Input:
- The first line contains the integer N (1 ≤ N ≤ 10^5), the number of book IDs.
- The second line contains N space-separated integers representing the book IDs.
Output:
- Print 'Duplicate' if there exists any duplicate book ID, otherwise print 'Unique'.
Example:
Input:
5
100 200 300 200 400
Output:
Duplicate
Key concepts
binary_searchsearchingarrays
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