【leetcode】最长回文串

 

int longestPalindrome(char * s){
    int hash[58] = {0};
    int i,oodMax=0,len=strlen(s),sum=0;
    for (i=0; i<len; i++)
    {
        hash[s[i]-'A']++;
    }
    for (i=0; i<58; i++)
    {
        sum += hash[i] - hash[i] % 2;
    }
    return sum+(sum != len);
}

 

posted @ 2020-09-22 14:41  温暖了寂寞  阅读(85)  评论(0编辑  收藏  举报