Problem :

https://leetcode.com/problems/palindromic-substrings/


My Solution :

class Solution:
    def countSubstrings(selfs):
        def count_palindrome(sleftright):
            count = 0
            while 0 <= left and right < len(s) and s[left] == s[right]:
                count += 1
                left -= 1
                right += 1
            return count

        ans = 0
        for i in range(len(s)):
            ans += count_palindrome(s, i, i)
            ans += count_palindrome(s, i, i+1)
        return ans