912. Sort an Array
给你一个阵列请排序他,时间复杂度最多O(nlogn),空间复杂度尽可能少。
Example:
Input: nums = [5,2,3,1]
Output: [1,2,3,5]
Explanation: After sorting the array, the positions of some numbers are not
changed (for example, 2 and 3), while the positions of other numbers are
changed (for example, 1 and 5).
思路:
1.因为题目需求时间复杂度O(nlogn),所以只能用高等排序来求解,其中HeapSort和
QuickSort空间用的最少所以挑这两个其一来实现即可。
Java Code: