I need to write a function that will return the number of possible different cyclic shifts of an input string.
Could you please give me some tips on where should I start in order to create an efficient (in terms of time complexity) algorithm? Should I begin with "preprocessing" the string and creating some data structure to help count the shifts later?
Simply store the string consecutively twice somewhere e.g.:
and then just move two index's from beginning to end of the first string "string length apart" along that double string, returning the interim string each time. Alternatively, you can work on your homework problems yourself.