Skip to content

Instantly share code, notes, and snippets.

@thmain
Created June 13, 2015 03:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thmain/3aa6dbfb5ef75840948f to your computer and use it in GitHub Desktop.
Save thmain/3aa6dbfb5ef75840948f to your computer and use it in GitHub Desktop.
public class RotatedArray {
public boolean isRotated(String s1, String s2){
if(s1.length()!=s2.length()){
return false;
}
String sAdd = s1 + s1;
if(sAdd.contains(s2)){
return true;
}else{
return false;
}
}
public static void main(String arg[]){
String s1 = "sumitjain";
String s2 = "tjainsumi";
RotatedArray r = new RotatedArray();
System.out.println("Is '" + s1 + "' and '" + s2 + "' are rotated?? : " + r.isRotated(s1, s2));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment