🔥 BEATS 100 %🔥✅ ||   Construct K Palindrome Strings in ONE PASS  💡|| Optimal Code Approach✅
IntuitionA string can be rearranged into a palindrome if at most one character has an odd frequency. Given k, we need to determine if we can construct exactly k
![Screenshot 2025-01-11 104057.png](https://assets.leetcode.com/users/images/1d19b529-88ab-40cd-a622-ad4cde973a8a_1736573127.2752535.png)

# Intuition
A string can be rearranged into a palindrome if at most one character has an odd frequency. Given `k`, we need to determine if we can construct exactly `k` palindromic strings.

1. If `s.length() < k`, it's impossible to form` k` non-empty strings, so return false.
2. We count the frequency of each character in `s`.
3. To form `k` palindromic strings, the minimum required is the number of characters with odd frequencies (since each must be placed in a separate palindrome).
4. If the number of characters with odd frequency `(oddCount) `is less than or equal to `k` , it's possible to construct k palindromes. Otherwise, return `false`.

# Approach
1. Edge Case: If `s.length() < k`, return `false`.
2. Character Frequency Count: Use an array `freq[26]` to store the count of each character.
3. Count Odd Frequencies: Traverse `freq` and count characters appearing an odd number of times.
4. Final Condition: If `oddCnt <= k`, return `true`, otherwise return `false`.


# Complexity
- Time complexity:
`𝑂(𝑛)`,where n is the length of `s` (we iterate through `s` and `freq` once).

- Space complexity: 
`O(1)` (constant extra space for `freq`, since it's fixed at size `26`)
# Code
```cpp []
class Solution {
public:
    bool canConstruct(string s, int k) {
        if(s.length()<k) return false;
        vector<int> freq(26,0);
        for(char c: s) freq[c-'a']++;
        int oddcnt = 0 ;
        for(int cnt:freq){
            if(cnt%2 == 1) oddcnt++;
        }
        return oddcnt<=k;
    }
};
```
### Upvote Plz 


['String', 'C++']