@theklam isn't the naive solution n^3? 1st, choose len of substring, which ranges from 1 to n. 2nd, choose a start point of substring, which ranges from 0 to n - i, where i is the choosed len of substring and n is the total len of given string. 3rdcheck whether substring is palindrome, which also cost O of n. Therefore, it's n^3 in total.

Palindromic Substrings