I was trying to solve the problem http://www.spoj.com/problems/MINMOVE/ but unfortunately couldn't. My solution idea is: 1.First of all I checked whether all the character is same or not. If it is same then the answer is O. Example: aaa answer should be O. 2.Otherwise, I have concatenate the string at the back of the string and then added a "$" at last. 3. Then I build the suffix array (O*Log(N)). 4. At last I traverse the suffix array whenever I got a value in the suffix array less then the string.size() I have printed the value.
Now, I have no idea what to do.Any help or suggestions would be appreciated. code: https://ideone.com/QHcYhW