💻🧠BEST SOLUTION✅| BEATS 100%⌛⚡| (C++/Java/Python3/Javascript)
IntuitionTo form a palindrome, all characters must have even counts, except for at most one character with an odd count (which can be placed in the middle of th
# **Intuition**  
To form a palindrome, all characters must have even counts, except for at most one character with an odd count (which can be placed in the middle of the palindrome).  
To construct `k` palindromes:
1. The number of palindromes cannot exceed the number of characters in the string (`k <= s.length`).
2. The number of palindromes must be at least equal to the number of characters with odd frequencies (`oddCount <= k`).

# **Approach**  
1. Count the frequency of each character in the string.
2. Calculate the number of characters with odd frequencies (`oddCount`).
3. Return `true` if the following conditions are met:
   - `k <= s.length` (not enough characters to form `k` palindromes).
   - `oddCount <= k` (each palindrome can accommodate one odd-count character).
4. Otherwise, return `false`.

# **Complexity**  
- **Time Complexity:**  
  - `O(n)`, where `n` is the length of the string. Counting frequencies and odd counts requires a single traversal.  
- **Space Complexity:**  
  - `O(1)` (for English letters, since the frequency array is fixed at size 26).

# **Code**  
 
``` C++ []
class Solution {
public:
    bool canConstruct(string s, int k) {
        if (k > s.size()) return false;
        int letterCount[26] = {0}, oddCount = 0;
        for (char c : s) {
            oddCount += (++letterCount[c - 'a'] & 1) ? 1 : -1;
        }return oddCount <= k;
    }
};
```
``` Python []
class Solution:
    def canConstruct(self, s: str, k: int) -> bool:
        if len(s) == k:
            return True
        if len(s) < k:
            return False
        odd = 0
        for char in set(s):
            if s.count(char) % 2:
                odd += 1
        if odd > k:
            return False
        return True
```

```Java []
class Solution {
    public boolean canConstruct(String s, int k) {
        if (s.length() < k) return false;
        if (s.length() == k) return true;

        int oddCount = 0;
        for (char chr : s.toCharArray()) {
            oddCount ^= 1 << (chr - 'a');
        }return Integer.bitCount(oddCount) <= k;
    }
}
```

```Javascript []
/**
 * @param {string} s
 * @param {number} k
 * @return {boolean}
 */
var canConstruct = function(s, k) {
    if (s.length < k) return false;
    const letters = new Array(26).fill(0);
    for (const char of s) {
        letters[char.charCodeAt(0) - 'a'.charCodeAt(0)]++;
    }
    const oddCount = letters.reduce((count, freq) => count + (freq % 2), 0);
    return oddCount <= k;
};

};
```

```
✨ AN UPVOTE WILL BE APPRECIATED ^_~ ✨
```

```
['Python', 'C++', 'Java', 'Python3', 'JavaScript']