[
string
palindrome
hash table
counter
]
BinarySearch 0456 Fleet of Palindromes
Problem statement
https://binarysearch.com/problems/Fleet-of-Palindromes/
Solution
The idea is that we can not have a lot of letters with odd
frequency and also that number of parts is less than length of string.
Complexity
It is O(n)
for time and space.
Code
class Solution:
def solve(self, s, k):
return sum(x % 2 == 1 for x in Counter(s).values()) <= k <= len(s)