Easy cpp Solution O(nlogn)


#1

vector Solution::wave(vector &A) {
sort(A.begin(),A.end());
for(int i=0;i<A.size()-1;i=i+2)
{
swap(A[i],A[i+1]);
}
return A;
}