HTMLify
LeetCode - Construct K Palindrome Strings - Python
Views: 299 | Author: abh
1 2 3 4 5 6 7 8 9 10 11 | class Solution: def canConstruct(self, s: str, k: int) -> bool: if len(s) < k: return False m = {} oc = 0 for c in set(s): m[c] = s.count(c) oc += 1 if m[c]%2 else 0 if oc > k: return False return True |