We’re preparing your current view and syncing the latest data.
You are given an array of integers nums. Your task is to sort the array in ascending order and return the sorted array. You are expected to come up with an efficient sorting algorithm implementation, ideally with average time complexity better than O(n^2).
An integer array nums of length n.
Return the array sorted in ascending order.
1 <= nums.length <= 5 * 10^4 -5 * 10^4 <= nums[i] <= 5 * 10^4
Example 1
Input
[5,2,3,1]
Output
[1,2,3,5]
Explanation
The sorted order of the array is [1, 2, 3, 5].
Example 2
Input
[5,1,1,2,0,0]
Output
[0,0,1,1,2,5]
Explanation
The sorted order of the array is [0, 0, 1, 1, 2, 5].