Permutation Sort
You are given a permutation $P$ of length $N$. In one operation, you can: - Select a set $S$ of **unique indices** $\{i_1, i_2, \ldots, i_K\}$ where: - $K$ is **even**; - $1\le i_j \le N$ for all $1\le j \le K$. - Swap the pairs $P_{i_1}$ with $P_{i_2}$, $P_{i_3}$ with $P_{i_4}$, $\ldots$, $P_{i_{(K-1)}}$ with $P_{i_K}$. Your task is to sort the permutation $P$ in increasing order using **at
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.
Sign in to chat with the tutor and save your progress.
Sign in to start