Java, counting, simple, explained
Idea is following: count of chars can be even or odd. Those that are even - they can be used in one of substrings to form the palindrome, so we don\'t care abou
Idea is following: count of chars can be even or odd. Those that are even - they can be used in one of substrings to form the palindrome, so we don\'t care about those.\nIf character has odd frequency - it can be inserted only 1 or 3 or 5... etc. to form the palindrome. However number of such characters cannot be more than number of strings, in other words - only one such char is allowed per substring. \nThis leads to solution - count all frequencies, count those that are odd. If number of such chars > then k - it\'s not possible to balance it to form all palindromes.\n\nO(n) time - iterate over every char in string to count freq.\nO(1) space - use fixed size array to count freq.\n\n```\n  public boolean canConstruct(String s, int k) {\n    if (s == null || s.isEmpty() || s.length() < k)\n      return false;\n    \n    int[] count = new int[26];\n    //count freq of every character\n    for (char ch : s.toCharArray()) ++count[ch - \'a\'];\n    //count chars that has odd freq\n    int countOfOdd = 0;\n    for (int i = 0; i < 26; i++) \n      if (count[i] % 2 == 1)\n        ++countOfOdd;\n    return countOfOdd <= k;\n  }\n```
['String', 'Java']