Skip to content

Instantly share code, notes, and snippets.

@ka8725
Created April 24, 2012 23:38
Show Gist options
  • Save ka8725/2484621 to your computer and use it in GitHub Desktop.
Save ka8725/2484621 to your computer and use it in GitHub Desktop.
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