This commit is contained in:
parent
1d01b3f104
commit
1d6dfd4f8d
1 changed files with 12 additions and 0 deletions
12
medium/construct_k_palindrome_strings.py
Normal file
12
medium/construct_k_palindrome_strings.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# https://leetcode.com/problems/construct-k-palindrome-strings
|
||||
|
||||
from typing import Counter
|
||||
|
||||
class Solution:
|
||||
def canConstruct(self, s: str, k: int) -> bool:
|
||||
if len(s) < k:
|
||||
return False
|
||||
c = Counter(s)
|
||||
odd = sum(v % 2 for v in c.values())
|
||||
return odd <= k
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue