← All problemsSign in

Ups and Downs

CodeChefRating 1198Open on judge ↗

Problem description You will be given a zero-indexed array A. You need to rearrange its elements in such a way that the following conditions are satisfied: - A[i] ≤ A[i+1] if i is even. - A[i] ≥ A[i+1] if i is odd. In other words the following inequality should hold: A[0] ≤ A[1] ≥ A[2] ≤ A[3] ≥ A[4], and so on. Operations ≤ and ≥ should alter. Input The first line contains a single integer T

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start