Skip to main content

Command Palette

Search for a command to run...

1400. Construct K Palindrome Strings

Published
1 min read
1400. Construct K Palindrome Strings
class Solution:
    def canConstruct(self, s: str, k: int) -> bool:
        l = len(s)

        if l < k:
            return False

        if l == k:
            return True

        c = Counter(s)

        oddCount = 0
        for e in c:
            if c.get(e) % 2 != 0:
                oddCount += 1

        return  oddCount <= k