Simple Solution in Java in O(nlogn)


#1

public class Solution {
public int[] wave(int[] A) {
Arrays.sort(A);
int temp;
for(int i=0;i<A.length-1;i+=2){
temp=A[i];
A[i]=A[i+1];
A[i+1]=temp;
}
return A;
}
}