Minimize the string
CodeChefOpen on judge ↗
You are given **n** strings **s1, s2, ..., sn**. Each of these strings consists only of letters 'a' and 'b', and the length of each string can be at most 2. In other words, the only allowed strings are "a", "b", "aa", "ab", "ba" and "bb". Consider a permutation **p** = {**p1**, **p2**, ..., **pn**} of the integers {1, 2, ..., **n**}. Using this permutation, you can obtain a new string **S = sp1 +
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