I'm confused by the running time of the following algorithm. I've been told it's $O(n^3)$, but there are only two loops. How can that be?
for(int i = 0; i < s.length(); ++i) {
for(int j = i; j <= s.length(); ++j) {
String sub = s.substring(i, j);
if(isPalindrome(sub) && sub.length() > maxCount) {
maxCount = sub.length();
longestP = sub;
}
}
}