1400. Construct K Palindrome Strings

Tapan RachchhTapan Rachchh
1 min read
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
0
Subscribe to my newsletter

Read articles from Tapan Rachchh directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Tapan Rachchh
Tapan Rachchh