Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- void wiggleSort(vector<int>& nums) {
- for(int i=0; i<nums.size()-1; i++){
- if(i%2 == 0){
- if(nums[i]>nums[i+1])
- swap(nums[i], nums[i+1]);
- }
- else{
- if(nums[i]<nums[i+1])
- swap(nums[i], nums[i+1]);
- }
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement