Untitled
unknown
plain_text
10 months ago
439 B
8
Indexable
class Solution {
public:
bool canConstruct(string s, int k) {
if(s.size()<k)return false;
vector < int > freq(27, 0);
for(int i=0;i<s.size();i++) {
freq[s[i]-'a']++;
}
int oddCount = 0;
for(int i=0;i<26;i++) {
if(freq[i] & 1) {
oddCount++;
}
}
if(oddCount<=k)return true;
return false;
}
};
//creee
//7Editor is loading...
Leave a Comment