Codeforces-Hongcow learns the cyclic shift

I tried to solve This question by every time shifting the string until shifted string is not equal to the initial string and increment count variable every time. Is there any more optimum way to do this.

The optimum way to solve it would be using Set of strings and inserting all the shifts of the original string in that set till you reach initial string and finally print the size of the set.

You may also take a look at the editorials of that round : CodeForces Round #385 Editorial

Hope this helps :slight_smile:

Yes, Optimum way is to use set. Here is my codeā€¦