class Solution {
public:
int longestPalindrome(string s) {
int hehe[128]={0};
for(int i = 0;i < s.length(); i++)
hehe[s[i]]++;
int flag = 0;
int sum = 0;
for(int i = 0;i < 128; i++){
sum += hehe[i] /2;
if(hehe[i] & 1) flag=1;
}
return flag+sum*2;
}
};
leetcode 409. Longest Palindrome
最新推荐文章于 2024-11-01 15:19:21 发布