2-Approaches : Better | Optimal.
Approach 1:
Store the count of all characters in vector.
Run a loop till 26-time.
If any count of character occur odd time so add in the 'cnt' variable.
If 'cnt
# Approach 1:
<!-- Describe your approach to solving the problem. -->
1. Store the count of all characters in vector.
2. Run a loop till 26-time.
3. If any count of character occur odd time so add in the 'cnt' variable.
4. If 'cnt' cross the 'k' so it cannot be palindrome.
# Complexity
- Time complexity: O(N + 26)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(26)
  Taking constant space for storing the count of small characters.

# Code
```cpp []
class Solution {
public:
    bool canConstruct(string s, int k) {
        if(k>s.size()) return 0;

        vector<int> words(26,0);
        for(auto it:s) words[it - 'a']++;
        int cnt = 0;
        for(int i=0;i<26;i++) if(words[i]%2==1) cnt++;
        return cnt<=k;
    }
};
```

# Approach 2:


# Complexity
- Time complexity: O(NlogN + N)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    bool canConstruct(string s, int k) {
        if (k > s.size())
            return 0;

        sort(s.begin(), s.end());
        int cnt = 1, check = 0;
        char pre = s[0];

        for (int i = 1; i < s.size() ; i++) {
            if (pre != s[i]) {
                check+=cnt%2;
                pre = s[i];
                cnt = 1;
            }
            else cnt++;

            if(check>k) return false;
        }
        check+=cnt%2;

        return check<=k;
    }
};
```
['C++']