🔥 Very Easy Detailed Solution  || 🔥 Beats 100% || 🎯 Three Approaches
Approach 1 : Frequency counting and condition checking based on odd/even characters

Count Character Frequencies:

The freq array keeps track of the frequency o
# Approach 1 : Frequency counting and condition checking based on odd/even characters
<!-- Describe your approach to solving the problem. -->
1. **Count Character Frequencies:**
    - The freq array keeps track of the frequency of each character in the string s.
    - The loop for(int i=0; i<n; i++) iterates through the string and increments the frequency of the respective character.

2. **Count Odd Frequencies:**
    - A palindrome requires all characters to have even frequencies, except for at most one character in the case of odd-length palindromes.
    - The loop for(int i : freq) counts how many characters have an odd frequency and stores this count in the variable count.

3. **Check Conditions:**
    - The string s can be rearranged into k palindromic substrings if:
        - The number of characters with odd frequencies (count) is less than or equal to k because each odd-frequency character requires its own  - palindrome.
        - k is less than or equal to the length of the string n because we cannot create more palindromic substrings than the total number of characters.
    - Return true if both conditions are satisfied; otherwise, return false.
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
$O(n)$
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
$O(1)$
# Code
```java []
class Solution {
    public boolean canConstruct(String s, int k) {
        int n = s.length();
        int freq[] = new int[26];
        for(int i=0; i<n; i++){
            char ch = s.charAt(i);
            freq[ch - 'a']++;
        }
        int count = 0;
        for(int i : freq){
            if(i%2 != 0){
                count++;
            }
        }
        return count <= k && k <= n;
    }
}
```

# Approach 2 : Sorting and counting odd frequencies
<!-- Describe your approach to solving the problem. -->
1. **Convert String to Character Array:**
    - The string s is converted to a character array arr to facilitate sorting.

2. **Sort the Character Array:**
    - Sorting the characters groups identical characters together. This makes it easier to calculate the frequency of each character in one traversal.

3. **Count Characters with Odd Frequencies:**
    - Use a loop to traverse through the sorted array. A nested while loop counts the frequency of each character by iterating through consecutive occurrences of the same character.
    - If a character has an odd frequency, increment the variable count, which tracks the number of characters with odd frequencies.

4. **Check Conditions:**
    - Similar to the previous solution, the string s can be rearranged into k palindromic substrings if:
        - The number of characters with odd frequencies (count) is less than or equal to k.
        - k is less than or equal to the total length of the string n.

5. **Return Result:**
    - Return true if both conditions are satisfied; otherwise, return false.
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
$O(nlogn)$
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
$O(n)$
# Code
```java []
class Solution {
    public boolean canConstruct(String s, int k) {
        int n = s.length();
        char arr[] = s.toCharArray();
        Arrays.sort(arr);
        int count = 0;
        for(int i=0; i<n; ){
            char ch = arr[i];
            int freq = 0;
            while(i < n && arr[i] == ch){
                freq++;
                i++;
            }
            if(freq%2 != 0){
                count++;
            }
        }
        return count <= k && k <= n;
    }
}
```

# Approach 3 : HashMap for counting odd frequencies and verifying conditions
<!-- Describe your approach to solving the problem. -->
1. **Count Character Frequencies:**
    - A HashMap<Character, Integer> (hm) is used to store the frequency of each character in the string s.
    - The for loop iterates through the characters of the string, updating the frequency of each character using the getOrDefault method.

2. **Count Odd Frequencies:**
    - A second loop iterates through the values of the HashMap (frequencies of the characters).
    - If a frequency is odd, increment the count variable. This keeps track of the number of characters with odd frequencies.

3. **Check Conditions:**
    - The string can be rearranged into k palindromic substrings if:
        - The number of characters with odd frequencies (count) is less than or equal to k because each odd-frequency character requires its own palindrome.
        - k is less than or equal to the length of the string n because we cannot create more substrings than there are characters in the string.

4. **Return Result:**
    - Return true if both conditions are satisfied; otherwise, return false.
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
$O(n)$
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
$O(m)$, where m is the number of unique characters in the string
# Code
```java []
class Solution {
    public boolean canConstruct(String s, int k) {
        int n = s.length();
        HashMap<Character, Integer> hm = new HashMap<>();
        for(char ch : s.toCharArray()){
            hm.put(ch, hm.getOrDefault(ch, 0) + 1);
        }
        int count = 0;
        for(int i : hm.values()){
            if(i%2 != 0){
                count++;
            }
        }
        return count <= k && k <= n; 
    }
}
```
['Array', 'Hash Table', 'Math', 'String', 'Ordered Map', 'Counting', 'Java']