Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func wiggleSort(_ nums: inout [Int]) {
- var sortedNums = nums.sorted()
- let n = nums.count
- for i in stride(from: 1, to:n , by: 2) {
- nums[i] = sortedNums.removeLast()
- }
- for i in stride(from: 0, to:n , by: 2) {
- nums[i] = sortedNums.removeLast()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement