Codeforces-Hongcow learns the cyclic shift

shift
string

#1

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.


#2

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:


#3

Yes, Optimum way is to use set. Here is my codeā€¦
http://codeforces.com/contest/745/submission/23067814