← All problemsSign in

Reflection Disorder

CodeChefRating 2953Open on judge ↗

Suppose $B$ is an array of length $M$. We define the *reflection* of $B$ as follows: - For each $i$ such that $1 \le i \lt M+1-i$, swap the $i$-th largest and $(M+1-i)$-th largest elements of $B$. That is, the *reflection* of $B$ is obtained by swapping its largest element with its smallest element, its second largest element with its second smallest, and so on. For example, if $B = [3, 5, 8

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