Question link: Challenge First
My Solution (Considered WA): Solution
The question is to rearrange the given array as:
- arr[i] > arr[i+1] < arr[i+2] > arr[i+3] …
- also arr[i] < arr[i+2] and arr[i+1] < arr[i+3]
The testcase and the solution given:
4 1 6 3 -> 3 1 6 4
4 5 1 6 3 -> 3 1 5 4 6
My solution to above testcases:
4 1 6 3 -> 4 1 6 3
4 5 1 6 3 -> 4 1 5 3 6
My solution is passing both the conditions asked in the question. But I am getting WA verdict.
Can someone help me regarding this…
@references