Solution Review: Array Waveform
Let’s take a detailed look at two solutions to the challenge set in the previous lesson.
First solution
Compare the value of every even index with the values of its previous and next odd indices. Swap the pair if the value at the odd index is not less than the value at the even index. The solution idea is presented in the following illustration.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.