← back to unit
Challenge
# searching advanced
The Last Time It Appears
Same sorted leaderboard — now find where the target score appears for the LAST time. 🏅
You get a SORTED list of nums (with repeats) and a target that appears at least once. Print the position of its last appearance, using the split-in-half strategy.
Example:
Input: nums = [1, 4, 4, 4, 7, 9], target = 4
Output: 3
Binary search lands on a 4, then keeps checking the right half until it finds the latest one, at position 3.
💡 need a hint?
srch-last-appearance.py🔒 given lines are locked — write your code in between
loading...