当前位置:网站首页>Force buckle 912 Sort array

Force buckle 912 Sort array

2022-07-07 20:06:00 Tomorrowave

Code section

Give you an array of integers nums, Please arrange the array in ascending order .
Example 1:
Input :nums = [5,2,3,1]
Output :[1,2,3,5]
Example 2:
Input :nums = [5,1,1,2,0,0]
Output :[0,0,1,1,2,5]

 Tips :
1 <= nums.length <= 5 * 104
-5 * 104 <= nums[i] <= 5 * 104

Ideas

Ascending order list.sort()

Code section

class Solution:
    def sortArray(self, nums: List[int]) -> List[int]:
        nums.sort()
        return nums
原网站

版权声明
本文为[Tomorrowave]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071753355784.html