0
点赞
收藏
分享

微信扫一扫

Leetcode 面试题 01.04. 回文排列


Leetcode ​​面试题 01.04. 回文排列​​

class Solution {
public:
bool canPermutePalindrome(string s) {
std::map<char,int> m;
for(char& ch : s)
{
m[ch]++;
}
std::map<char,int>::iterator it = m.begin();
int cnt = 0;
while(it != m.end())
{
if(it->second%2!=0)
cnt++;
it++;
}
return cnt < 2;
}
};

Leetcode 面试题 01.04. 回文排列_leetcode


举报

相关推荐

0 条评论