Swap Permutation 1
You are given a permutation $P$ of the integers $[1, N]$. Perform the following operation sequence: - For integers $i = 1, 2, ...N$ (in this order), perform one of the following actions: - Choose an integer $X$ such that $1 \le X < N$, and either $P_X = i$ or $P_{X + 1} = i$, then swap $P_X$ and $P_{X + 1}$. - Choose to do nothing. Let $f(P)$ denote the lexicographically smallest permut
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