Question bank › Binary Search
Dsa Binary Search Medium

Mystery Number Guessing

You are playing a guessing game. A mystery number is hidden in a sorted list of unique numbers. Given a list of numbers and your guessed number, determine the index of the guessed number if it exists. If it doesn't exist, return -1. Implement a function that takes the input accordingly. Input Format: - The first line contains an integer N, the number of unique numbers. - The second line contains N space-separated integers representing the sorted numbers. - The third line contains your guessed number. Output Format: - Print the index of the guessed number, or -1 if it does not exist. Example: Input: 5 2 3 4 5 6 4 Output: 2

Key concepts

binary_searchsearchingguessing

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.