🧩Form K Palindromes ✨with Minimal Effort 🧠✅
Intuition 🤔✨We need to check if the string s can be split into k palindromes.
Palindrome Fact: Only odd-frequency characters matter when forming palindromes (si
# Intuition 🤔✨
We need to check if the string s can be split into k palindromes.

- Palindrome Fact: Only odd-frequency characters matter when forming palindromes (since the middle character can stay unmatched).
- So, the question boils down to:
    1. Count the characters with odd frequencies.
    2. Check if we can manage them within the given k palindromes.

---

# Approach 🛠️📝
1. Base Case:
    - If s.length < k, it's impossible to form k substrings. ❌
2. Frequency Count:
    - Count how often each character appears using a frequency array (or hash map). 📊
3. Count Odds:
    - Count the characters with odd frequencies. 🔢
4. Check Feasibility:
    - If the number of odd-frequency characters is greater than k, return false. Otherwise, it's possible! ✅


---

# Complexity ⏱️⚡
## Time Complexity:
- Counting frequencies 🕒: O(n), where n is the length of the string.
- Checking odd frequencies 🕒: O(26) ≈ O(1) (since the alphabet size is constant).

-      Total: O(n).
## Space Complexity:

-        Frequency storage 📂: O(26) ≈ O(1).


---

# Code
```cpp []
class Solution {
public:
    bool canConstruct(string s, int k) {
        if(s.size() < k) return false ;
        vector<int> freq(26, 0);
        int cnt = 0;

        for (auto& ch : s) {
            freq[ch - 'a']++;
        }

        for (auto& it : freq) {
            if (it % 2 != 0) {
                cnt++;
            }
        }

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

        int[] freq = new int[26];
        int oddCount = 0;

        for (char ch : s.toCharArray()) {
            freq[ch - 'a']++;
        }

        for (int count : freq) {
            if (count % 2 != 0) {
                oddCount++;
            }
        }

        return oddCount <= k;
    }
}

```
```javascript []
var canConstruct = function(s, k) {
    if (s.length < k) return false;

    let freq = Array(26).fill(0);
    let oddCount = 0;

    for (let ch of s) {
        freq[ch.charCodeAt(0) - 'a'.charCodeAt(0)]++;
    }

    for (let count of freq) {
        if (count % 2 !== 0) {
            oddCount++;
        }
    }

    return oddCount <= k;
};

``` 
```python []
class Solution:
    def canConstruct(self, s: str, k: int) -> bool:
        if len(s) < k:
            return False
        
        freq = [0] * 26
        for ch in s:
            freq[ord(ch) - ord('a')] += 1
        
        odd_count = sum(1 for count in freq if count % 2 != 0)
        return odd_count <= k

```
```ruby []
def can_construct(s, k)
    return false if s.length < k
    
    freq = Array.new(26, 0)
    s.each_char { |ch| freq[ch.ord - 'a'.ord] += 1 }
    
    odd_count = freq.count { |count| count % 2 != 0 }
    odd_count <= k
end

```
```rust []
impl Solution {
    pub fn can_construct(s: String, k: i32) -> bool {
        if s.len() < k as usize {
            return false;
        }

        let mut freq = vec![0; 26];
        let mut odd_count = 0;

        for ch in s.chars() {
            freq[(ch as usize - 'a' as usize)] += 1;
        }

        for count in freq {
            if count % 2 != 0 {
                odd_count += 1;
            }
        }

        odd_count <= k
    }
}

```
```c# []
public class Solution {
    public bool CanConstruct(string s, int k) {
        if (s.Length < k) return false;

        int[] freq = new int[26];
        int oddCount = 0;

        foreach (char ch in s) {
            freq[ch - 'a']++;
        }

        foreach (int count in freq) {
            if (count % 2 != 0) {
                oddCount++;
            }
        }

        return oddCount <= k;
    }
}

```
```go []
func canConstruct(s string, k int) bool {
    if len(s) < k {
        return false
    }

    freq := make([]int, 26)
    oddCount := 0

    for _, ch := range s {
        freq[ch-'a']++
    }

    for _, count := range freq {
        if count%2 != 0 {
            oddCount++
        }
    }

    return oddCount <= k
}

```
```swift []
class Solution {
    func canConstruct(_ s: String, _ k: Int) -> Bool {
        if s.count < k {
            return false
        }

        var freq = [Int](repeating: 0, count: 26)
        var oddCount = 0

        for ch in s {
            freq[Int(ch.asciiValue! - Character("a").asciiValue!)] += 1
        }

        for count in freq {
            if count % 2 != 0 {
                oddCount += 1
            }
        }

        return oddCount <= k
    }
}

``` 

['Swift', 'Counting', 'Python', 'C++', 'Java', 'Go', 'Rust', 'Ruby', 'JavaScript', 'C#']