LIKE DOLLS TOGETHER
CodeChefOpen on judge ↗
Tracy has $N$ dolls and arranged has arranged them in a row. Every doll has a hair stye and some dolls can have same hair styles also. The hairstyle of ith doll is represented by ai. Now, Tracy wants to rearrange the dolls such that the dolls with same hairstyle come together. To achieve his goal, Tracy can do the following operation any number of times: choose two neighboring dolls, and swap them
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