Sir says all numbers are unique and no number is repeating but in one the example ( 7,3,4,2,7,8 ) 7 is repeating two times , then why this code is valid . PLS EXPLAIN IN BRIEFLY .
CPP - Wave Sort
Hello @Nikhil-Aggarwal-2320066674901389,
This is because you have to compare each element with its right and left element only, instead of the entire array.
The number at even index (say i) should be greater then element at i-1 and i+1 irrespective of the other elements in the array.
Hope, i have cleared your doubt.
Give a like, if you are satisfied.