-
-
Notifications
You must be signed in to change notification settings - Fork 298
/
Copy path324.py
21 lines (21 loc) · 887 Bytes
/
324.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
__________________________________________________________________________________________________
sample 180 ms submission
class Solution:
def wiggleSort(self, nums: List[int]) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
nums.sort()
mid=len(nums[::2])
nums[::2],nums[1::2]=nums[:mid][::-1],nums[mid:][::-1]
__________________________________________________________________________________________________
sample 14024 kb submission
class Solution:
def wiggleSort(self, nums: List[int]) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
nums.sort()
mid = (len(nums) + 1) // 2
nums[::2], nums[1::2] = nums[:mid][::-1], nums[mid:][::-1]
__________________________________________________________________________________________________