写了一堆像狗屎的判断是
跟小丑一样
我的智商就这样了
def canConstruct(self, s: str, k: int) -> bool:
cnt = [0 for _ in range(26)]
for c in s:
cnt[ord(c)-ord('a')] += 1
odd_cnt = [num%2==1 for num in cnt].count(True)
if odd_cnt>k:
return False
elif len(s)<k:
return False
elif (len(s)-odd_cnt)/2<(k-odd_cnt) and len(s)-k<0:
return False
return True