class Solution(object):
def wiggleSort(self, nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
"""
"""
https://discuss.leetcode.com/topic/32861/3-lines-python-with-explanation-proof
"""
nums.sort()
half = len(nums[::2])
nums[::2], nums[1::2] = nums[:half][::-1], nums[half:][::-1]
leetcode 324. Wiggle Sort II
猜你喜欢
转载自blog.csdn.net/Kexiii/article/details/78018058
今日推荐
周排行