Beginner friendly 💯 💯 || Clean code ✅✅✅
IntuitionYou want to check if it's possible to rearrange the string s into exactly k palindrome substrings.Observations:

A palindrome reads the same backward a
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
You want to check if it's possible to rearrange the string s into exactly k palindrome substrings.

# **Observations**:

- A palindrome reads the same backward as forward.
 **For a string to be a palindrome:**
- At most one character can have an odd frequency (in the case of odd-length palindromes).
- All other characters must have even frequencies to "pair up."
**Key Observations:**

- To form k palindrome substrings, there must be at most k characters in s with an odd frequency.
- If k is greater than the length of the string `k > s.length()`, it's impossible to split s into k substrings (not enough characters).
# Approach
<!-- Describe your approach to solving the problem. -->
1. **Immediate Check:**

- If k is greater than the length of the string (k > s.length()), return false because it's impossible to split the string into k substrings.
2. **Count Character Frequencies:**

- Use a HashMap to count the frequency of each character in s.
3. **Count Odd Frequencies:**

- Iterate over the map to count how many characters have an odd frequency (odd).
- If the number of odd frequencies exceeds k, return false, because you can't form enough palindromes with those odd characters.
4. **Final Check:**

- If the number of odd frequencies is less than or equal to k, return true.
# Complexity
- Time complexity: $$O(n)$$
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

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

# Code
```java []
class Solution {
    public boolean canConstruct(String s, int k) {
        if(k>s.length()) return false;
        Map<Character,Integer> map=new HashMap<>();
        for(char c:s.toCharArray()){
            map.put(c,map.getOrDefault(c,0)+1);
        }
        int odd=0;
        for(char c:map.keySet()){
            if(map.get(c) %2!=0){
                odd++;
            }
            if(odd > k){
                return false;
            }
        }
        return true;
    }
}
```
['Hash Table', 'Java']