Construct K Palindrome Strings

Given a string s and an integer k, return true if you can use all the characters in s to construct non-empty k palindrome strings, or false otherwise.

Example 1
Inputs = "annabelle", k = 2
Outputtrue
You can construct two palindromes using all characters in s, such as "anna" + "elble".
Example 2
Inputs = "leetcode", k = 3
Outputfalse
It is impossible to construct 3 palindromes using all the characters of s.

Constraints

  • 1 <= s.length <= 10^5
  • s consists of lowercase English letters.
  • 1 <= k <= 10^5

Asked at 6 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate