Puppet Show
CodeChefOpen on judge ↗
$N$ children are watching a puppet show standing in a queue. Some of them are unable to enjoy the show because of a taller (strictly taller) child in front of them. Help them to reorder themselves such that everyone enjoys the show. The Show has already begun so you have to do it as quickly as possible. [Note: One swap takes one unit of time. A swap is an exchange of positions of two children.] #
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