Feb 1, 2009

the problem of finding the number of different cyclic shifts of a string that results in the same string

the problem of finding the number of different cyclic shifts of a string that results in the same string
For abab the answer is 2: cyclic shift at index 0 and 2
string ss = str+str; //str is the input
int ans = str.size()/ss.find(str, 1); //ans is the reqd answer

No comments:

Post a Comment