Created
April 24, 2012 23:38
-
-
Save ka8725/2484621 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 class AkariDaisukiDiv2 { | |
public int countTuples(String s) { | |
if (s.length() < 4) { | |
return 0; | |
} | |
int res = 0; | |
for (int i = 2; i < s.length() - 2; i++) { | |
for (int j = i + 2; j < s.length(); j++) { | |
String s1 = s.substring(0, i); | |
String s2 = s.substring(i, j); | |
int t = 1; | |
while (s1.substring(s1.length() - t).equals(s2.substring(s2.length() - t)) && | |
s1.length() > t && s2.length() > t) { | |
t++; | |
} | |
res += (t - 1); | |
} | |
} | |
return res; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment