Skip to content

Instantly share code, notes, and snippets.

@kimki1124
Created August 6, 2017 12:58
Show Gist options
  • Save kimki1124/f4070560ab8b62cd4290c918cc28587c to your computer and use it in GitHub Desktop.
Save kimki1124/f4070560ab8b62cd4290c918cc28587c to your computer and use it in GitHub Desktop.
public static int shiftedDiff(String first, String second){
if(first.equals(second)){
return 0;
}
for(int i=0;i<first.length();i++){
String temp = first.substring(0, first.length()-1);
temp = first.charAt(first.length()-1) + temp;
first = temp;
if(first.equals(second)){
return i+1;
}
}
return -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment