Skip to content

Commit 4b8ab77

Browse files
committed
Runtime: 133 ms (Top 67.12%) | Memory: 47 MB (Top 71.23%)
1 parent 8cc0516 commit 4b8ab77

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
// Runtime: 133 ms (Top 67.12%) | Memory: 47 MB (Top 71.23%)
12

23
var wiggleSort = function(nums) {
34
nums.sort((a,b) => a - b);
4-
5+
56
let temp = [...nums];
6-
7+
78
let low = Math.floor((nums.length-1)/2), high = nums.length-1;
8-
9+
910
for(let i=0; i < nums.length; i++){
1011
if(i % 2 === 0){
1112
nums[i] = temp[low];
@@ -15,6 +16,6 @@ var wiggleSort = function(nums) {
1516
high--;
1617
}
1718
}
18-
19+
1920
return nums;
2021
};

0 commit comments

Comments
 (0)