← All problemsSign in

Shifu and his Army

Commander Shifu is preparing his army. His cadet has given him a troop of $N$ soldiers, each of them having a specific associativity $a_i$. If two soldiers have the same associativity value, they tend to form a group i.e. they will go to war together whatsoever the orders are. Commander Shifu orders them to stand in a queue in increasing order of their associative value. Shifu has $K$ wars to fig

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