← All problemsSign in

Swap and Sort

Shreyas recently became 5 star on codechef and is obsessed with sorting. He creates his own algorithm Shrey-Sort wherein he sorts the array in non decreasing order only by swapping with certain constraints as given below. In Shrey-Sort one can perform operations on the array. In each operation one can choose $i$ and $j$ and swap $a_i$ and $a_j$ only if $a_i+a_j$ is even. Operations can be perfo

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