其他分享
首页 > 其他分享> > 647. 回文子串_动态规划

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")

 

标签:子串,count,res,Solution,len,range,647,countSubstrings,回文
来源: https://blog.csdn.net/moshiyaofei/article/details/99889154