Ranks Without Gaps
Return the rank of each score: the highest score has rank 1, equal scores share a rank, and the next lower score gets the next rank, with no ranks skipped. No loops: for and while are not allowed.
Example 1
scores [50,80,80,20]
returns [2,1,1,3]
The two 80s share rank 1, 50 is rank 2 and 20 is rank 3.
Constraints
1 <= len(scores) <= 1000 <= scores[i] <= 50
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More NumPy problems
- Record HighsMedium
- Risk of a MixMedium
- Row SharesMedium
- Sort by First ColumnMedium
- Subtract Row MinimumMedium
- Unit VectorsMedium
- Best Square BlockHard
- Crossing AboveHard