Created
August 6, 2017 12:58
-
-
Save kimki1124/f4070560ab8b62cd4290c918cc28587c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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