C++ solution in 3 lines


#1

vector Solution::wave(vector &A) {
sort(A.begin(),A.end());

for(int i = 1;i < A.size();i++){
    swap(A[i-1],A[i]);
    i++;
    
}
return A;

}


#2

bro is swap function is predefined??


#3

its a standard Library (STL)