TODO
描述
Given an array of integers nums
, sort the array in ascending order.
Example 1:
1 | Input: nums = [5,2,3,1] |
Example 2:
1 | Input: nums = [5,1,1,2,0,0] |
Constraints:
1 <= nums.length <= 5 * 104
-5 * 104 <= nums[i] <= 5 * 104
分析
面试必考…可以总结一下各种排序方法。
解决方案1(Python)
快速排序
会超时
1 | class Solution: |
冒泡排序
会超时。
1 | class Solution: |
选择排序
会超时。
1 | class Solution: |
插入排序
1 | class Solution: |
解决方案2(Golang)
快速排序
1 | func quickSort(arr []int, left, right int) []int { |