Return Integers in Descending Ranked Order
Company: Yelp
Role: Data Scientist
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Technical Screen
Overview: Return every integer in descending ranked order while preserving duplicates. This final coding follow-up builds on earlier maximum-of-two and maximum-of-list warm-ups.
Read the full Yelp Data Scientist interview experience this question came from
Constraints
- 0 <= values.length <= 200000
- -1000000000 <= values[i] <= 1000000000
- Duplicate values must be preserved
- Return values in nonincreasing order
Examples
Input: ([4, 1, 4, -2, 3],)
Expected Output: [4, 4, 3, 1, -2]
Explanation: The source example is ranked from greatest to least while preserving both copies of 4.
Input: ([],)
Expected Output: []
Explanation: An empty input has an empty descending ranking.
Hints
- Use a sorting operation configured for descending numeric order.
- Do not remove duplicate occurrences.