# Solution for Spongebob Musical https://acm.cs.nthu.edu.tw/problem/13996/ Essentially, checking for palindromes is just simultaneously checking the characters from both sides to see if any of them are all the same. If there is one that is not the same, then it isn't a palindrome. The challenge in this question is that you must check for every palindrome in the string. The solution is to use 2 for loops to provide a range to check for palindromes. ```cpp= #include <stdio.h> #include <stdbool.h> #include <string.h> bool isPalindrome(const char *str) { int left = 0; int right = strlen(str) - 1; if(strlen(str) < 3) { return false; } while (left < right) { if (str[left] != str[right]) { return false; } left++; right--; } return true; } int detectPalindrome(const char *str) { int counter = 0; int len = strlen(str); for(int i = 0; i < len; i ++) { for(int j = i; j < len; j ++) { char temp[1001]; int k = i; int idx = 0; while(k <= j) { temp[idx] = str[k]; k++; idx++; } temp[idx] = '\0'; if(isPalindrome(temp)) { counter++; } } } return counter; } int main() { char input[1001]; scanf("%s", input); int count = detectPalindrome(input); printf("%d\n", count); return 0; } ``````