Best Solution for Arrays 🚀 in C++, Python and Java || 100% working
Intuition💡 First, we observe that a palindrome can only have at most one character with an odd frequency. If there are more odd-frequency characters than k, it'
# Intuition  
💡 First, we observe that a palindrome can only have at most **one character with an odd frequency**. If there are more odd-frequency characters than `k`, it's impossible to split the string into `k` palindromes.  

# Approach  
1. 🧮 Count the frequency of each character.  
2. 🔢 Count how many characters have odd frequencies.  
3. ❌ If the number of odd frequencies is greater than `k`, return `False`. Otherwise, return `True`.  

# Complexity  
- Time complexity: $$O(n)$$, where $$n$$ is the length of the string.  
- Space complexity: $$O(1)$$ (using a fixed array for character frequency).  

# Code
```cpp []
class Solution {
public:
    bool canConstruct(string s, int k) {
        vector<int> arr(26, 0);
        int n = s.length();
        if (n < k) return false;
        for (char &x : s) arr[x - 'a']++;
        int odd = 0;
        for (int b : arr) if (b % 2 == 1) odd++;
        return (k >= odd);
    }
};
```

```python []
class Solution:
    def canConstruct(self, s: str, k: int) -> bool:
        from collections import Counter
        n = len(s)
        if n < k: return False
        odd = sum(1 for count in Counter(s).values() if count % 2 == 1)
        return k >= odd
```

```java []
class Solution {
    public boolean canConstruct(String s, int k) {
        int[] arr = new int[26];
        int n = s.length();
        if (n < k) return false;
        for (char x : s.toCharArray()) arr[x - 'a']++;
        int odd = 0;
        for (int b : arr) if (b % 2 == 1) odd++;
        return k >= odd;
    }
}
```
<img src="https://assets.leetcode.com/users/images/7b864aef-f8a2-4d0b-a376-37cdcc64e38c_1735298989.3319144.jpeg" alt="upvote" width="150px">

# Connect with me on LinkedIn for more insights! 🌟 Link in bio
['Hash Table', 'String', 'Greedy', 'Counting', 'Python', 'C++', 'Java', 'Python3']