← All problemsSign in

Interesting Swap

CodeChefRating 3115Open on judge ↗

**Please note that this problem has subtasks**. You are given a string $S$ of length $N$. In one operation, you can select a **non-empty** *prefix* and a **non-empty** *suffix* which do **not intersect**; and swap them. For example let $S =$ `avfdgs`. In one operation, you can choose *prefix* of length $2$ and *suffix* of length $3$, and swap them to make $S =$ `dgsfav`. Your task it to **sor

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