647. 회문자열동적 기획

class Solution(object):
    def countSubstrings(self, s):
        """
        :type s: str
        :rtype: int
        """
        res=[None]*len(s)

        count=0

        for i in range(len(s)):
            res[i]=1
            count+=1

            for j in range(i):
                if s[j]==s[i] and res[j+1]==1:
                    res[j]=1
                    count+=1
                else:
                    res[j]=0

        return count

# print Solution().countSubstrings("abc")

좋은 웹페이지 즐겨찾기