Question bank › Binary Search
Dsa Binary Search Hard

ID Number Search

You are given a sorted list of unique ID numbers and a target ID number. Your task is to determine if the target ID exists in the list and return its index if found. If the ID is not present, return -1. Input format: - The first line contains an integer n (1 <= n <= 10000): the number of IDs. - The second line contains n unique integers (1 <= ids[i] <= 1000000): the sorted list of ID numbers. - The third line contains an integer target (1 <= target <= 1000000): the target ID number to search. Output format: - A single integer representing the index of the target ID number or -1 if not found. Example: Input: 5 1000 2000 3000 4000 5000 3000 Output: 2

Key concepts

binary_searcharrayssearching

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.