Dsa
Binary Search
Warm-up
Exam Score Locator
You are given a sorted list of students' exam scores. Your task is to locate the index of a specific score using binary search. If the score does not exist in the list, return -1.
Input format:
- The first line contains an integer n (1 ≤ n ≤ 1000) indicating the number of scores.
- The second line contains n space-separated integers representing the exam scores.
- The third line contains an integer representing the score you need to search for.
Output format:
- Print a single integer: the index of the score, or -1 if not found.
Example:
Input:
4
60 70 80 90
70
Output:
1
Key concepts
binary_searcharraysearch
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