Beats 100% || 2Approaches
Complexity
Time complexity:
Approach 1 - O(N)
Approach 2 - O(N)
Code

# Complexity
- Time complexity:
Approach 1 - O(N)
Approach 2 - O(N)
# Code
```cpp []
//Approach 1
class Solution {
public:
    bool canConstruct(string s, int k) {
        int n = s.size();
        if(k>n)return false;
        int odd = 0;
        int even = 0;
        vector<int>freq(26,0);
        for(int i=0;i<n;i++){
            freq[s[i]-'a']++;
        }
        for(int i=0;i<freq.size();i++){
            if(freq[i]%2==0)even++;
            else odd++;
        }
        if(odd>k)return false;
        return true;
    }
};
//Approach 2
class Solution {
public:
    bool canConstruct(string s, int k) {
        int n = s.size();
        if(k>n)return false;
        int oddchar = 0;
        
        for(int i=0;i<s.size();i++){
            oddchar ^= 1<<(s[i]-'a');
        }
        int odd = __builtin_popcount(oddchar);
        if(odd>k)return false;
        return true;
    }
};
```
['Hash Table', 'String', 'Greedy', 'Counting', 'C++']