Ex:- "code" ==> "code" "odec" "deco" "ecod"
"heist" ==> "heist" "eisth"
"isthe" "sthei" "theis"
Java
1 2 3 4 5 6 7 8 9 | public class Rotation{ public static void main(String[] args){ String str = "codeheist"; for(int i=0; i<str.length(); i++){ String ans = str.substring(i,str.length()) + str.substring(0,i); System.out.println(ans); } } } |
Python
input_str = "codeheist" for i in range(0,len(input_str)): print( input_str [ i : len(input_str) ] + input_str [ 0 : i ] ) |