Help in Codeforces problem Pasha and String

In the editorial of the problem Pasha and String, the author makes a claim that, “it doesn’t matter in which order make reverses, answer will be the same for all orders.”
What is the reasoning behind this statement? Is it because the rotation of string is always symmetric about the center(from the position i to |s| - i + 1)?

Yes, that is correct. A rotation causes changes in positions of characters, but a character at i is always swapped with that at |s|-i+1. So the only thing which is important with regard to a pair of positions (i, |s|-i+1) is the number of rotations that affect them.

1 Like