← back to unit
Medium
# sorting medium
The Missing Rank
Ranks 1 through n were handed out, one kid went home early, and the pile is shuffled. 🏠
You get the shuffled ranks with exactly one rank missing. Sort them and find the gap. Print the missing rank. (Careful — the missing one might be the very last!)
Example:
Input: ranks = [4, 1, 2, 5]
Output: 3
Sorted, the list becomes [1, 2, 4, 5] — position 2 should hold 3 but holds 4 instead, revealing the gap.
💡 need a hint?
sort-missing-rank.py🔒 given lines are locked — write your code in between
loading...