647. Palindromic Substrings

def countSubstrings(self, s):
        """
        :type s: str
        :rtype: int
        """
        ans, size = 0, len(s)
        for center in xrange(2 * size - 1):
            left = center / 2
            right = left + center % 2
            while left >= 0 and right < size and s[left] == s[right]:
                ans += 1
                left -= 1
                right += 1
        return ans

results matching ""

    No results matching ""