Official algorithmic problem description and constraints.
You are given a string π of length π, containing only the characters a, b, and c.
In one move, you can modify π as follows:
abc.a or the c from π, that is, either index π or index π.For example, if π=cbbaβΎcbβΎacβΎc, you can choose π=4,π=6,π=8 (the underlined indices), and then delete either index 4 (obtaining π=cbbcbacc) or index 8 (obtaining π=cbbacbac).
Find the minimum number of moves that can be made on π, such that it's impossible to perform any further moves on the resulting string.
Detailed video explanations, mathematical intuition, and clean C++ implementation code.