← back to unit
Challenge
# searching advanced
The First Time It Appears
The score 90 shows up several times on the sorted leaderboard — but who reached it FIRST in the rankings? 🏅
You get a SORTED list of nums (with repeats) and a target that appears at least once. Print the position of its FIRST appearance — and no fair scanning one by one!
Example:
Input: nums = [1, 4, 4, 4, 7, 9], target = 4
Output: 1
Binary search lands on a 4, then keeps checking the left half until it finds the earliest one, at position 1.
💡 need a hint?
srch-first-appearance.py🔒 given lines are locked — write your code in between
loading...