楼主:
dont 2025-01-11 17:07:151400. Construct K Palindrome Strings
## 思路
1.字串长度必须要大于K
2.回文: AABB / ABA
计算字符的奇偶个数 最多只能有K个字符是奇数个
## CODE
```CPP
class Solution {
public:
bool canConstruct(string s, int k) {
if (k > s.length())
return false;
vector<int> count(26, 0);
for (char& ch: s) {
++count[ch-'a'];
}
for (int i=0; i<26; ++i) {
k -= (count[i] & 1);
}
return k >= 0;
}
};
```