647. Palindromic Substrings

来源:互联网 发布:大麦盒子刷机 网络限制 编辑:程序博客网 时间:2024/06/05 05:01

暴力求解

class Solution {public:    bool judge(int i,int j,string s)    {        while(i<j)        {            if(s[i]!=s[j])                return false;            else            {                i++;                j--;            }        }        return true;    }    int countSubstrings(string s) {        int count = 0;        for(int i = 0;i<s.size();i++)        {            for(int j = i;j<s.size();j++)            {                if(judge(i,j,s))                    count++;            }        }        return count;    }};
原创粉丝点击