String Reduction
CodeChefOpen on judge ↗
Given a string consisting of the letters $a$, $b$ and $c$, we can perform the following operation: -Take any two adjacent distinct characters and replace them with the third character. Find the shortest string obtainable through applying this operation repeatedly. For example, given the string $aba$ we can reduce it to a 1 character string by replacing $ab$ with $c$ and $ca$ with $b$: $aba$ ->
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