We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents e4abf3b + 5afd476 commit 23e2af3Copy full SHA for 23e2af3
python/0280-wiggle-sort.py
@@ -0,0 +1,5 @@
1
+class Solution:
2
+ def wiggleSort(self, nums: List[int]) -> None:
3
+ for i in range(1, len(nums)):
4
+ if (i % 2 == 1 and nums[i] < nums[i - 1]) or (i % 2 == 0 and nums[i] > nums[i - 1]):
5
+ nums[i], nums[i - 1] = nums[i - 1], nums[i]
0 commit comments