Check if the given strings are rotated form of each other.
The approach is to check if the strings are of same length, then check if s2 is sub-string of s1 concatenated with itself.
The approach is to check if the strings are of same length, then check if s2 is sub-string of s1 concatenated with itself.
public static boolean isRotated(String s1,String s2){ return s1.length()==s2.length() && (s1+s1).indexOf(s2)!=-1 ; }Read full article from Coding Recipies: Rotated Strings