← All problemsSign in

Array sorting

CodeChefRating 1681Open on judge ↗

You are given an **unsorted** permutation $P$ of size $N$. An operation is defined as: - Swap $P_i$ and $P_{i+K}$ for any $i$ in the range $[1,N-K]$. Find the **maximum** value of $K$, such that, the permutation $P$ can be **sorted** by applying any finite number of operations. Note that, a permutation of size $N$ contains all integers from $1$ to $N$ **exactly** once. ### Input - The first li

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