Dsa
Binary Search
Medium
Movie Rating Search
You are running a movie rating system. Given a sorted list of unique movie ratings and a target rating, implement a program that finds the exact rating's index. If the target does not exist, return the index where it could be inserted to maintain the sorted order.
Input Format:
- The first line contains a space-separated list of integers (movie ratings).
- The second line contains a single integer (target rating).
Output Format:
- A single integer representing the index of the target rating or the position to insert it.
Example:
Input:
1 3 5 7 9
6
Output:
3
Key concepts
binary_searcharraysratings
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