Dsa
Binary Search
Medium
Gig Economy Task Search
In a gig economy app, users can search for available tasks based on their ratings. Given a sorted list of task ratings and a target rating, return the index of the first task that meets or exceeds the target rating. If no such task exists, return -1.
Input format:
- The first line contains an integer n, the number of tasks.
- The second line contains n sorted integers (the task ratings).
- The third line contains an integer target rating t.
Output format:
- Print the index of the first task that meets or exceeds t or -1 if not found.
Example:
Input:
5
1 2 3 4 5
3
Output:
2
Key concepts
binary_searcharraystask_management
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