Sort an Array — Sorting & Divide-and-Conquer
Arrange all scores, duplicates included, from lowest to highest.
Sorting & Divide-and-Conquer · Easy
The problem
A leaderboard needs its scores in order from lowest to highest. Given a list of integers, return the same values arranged from smallest to largest.
The story
A leaderboard of scores needs its scores in order. Return every score, repeats included, sorted from smallest to largest.
What to return
- Return a new list (or the same list) holding every input value, in non-decreasing order.
- Repeated values stay repeated.
Constraints
- 0 <= nums.length <= 2500
- -1000000 <= nums[i] <= 1000000
- Your code may run at most 381,284 counted steps on the largest case.
Example
- Input
nums = [7, 2, 9, 4]- Output
[2, 4, 7, 9]