My 2 Line Python Code


  • 0

    class Solution(object):
    def wiggleSort(self, nums):
    """
    :type nums: List[int]
    :rtype: void Do not return anything, modify nums in-place instead.
    """
    for i in xrange(len(nums) - 1):
    [nums[i], nums[i + 1]] = [min(nums[i], nums[i + 1]), max(nums[i], nums[i + 1])] if i % 2 == 0 else [max(nums[i], nums[i + 1]), min(nums[i], nums[i + 1])]


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.