Skip to content

Commit cb46698

Browse files
committed
Jan 11
1 parent 99fca3a commit cb46698

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from collections import Counter
2+
3+
4+
class Solution:
5+
def canConstruct(self, s: str, k: int) -> bool:
6+
if k > len(s):
7+
return False
8+
n_odds = sum(c & 1 for c in Counter(s).values())
9+
return n_odds <= k
10+
11+
12+
def main():
13+
s = 'annabelle'
14+
k = 2
15+
assert Solution().canConstruct(s, k) is True
16+
17+
s = 'leetcode'
18+
k = 3
19+
assert Solution().canConstruct(s, k) is False
20+
21+
s = 'true'
22+
k = 4
23+
assert Solution().canConstruct(s, k) is True
24+
25+
26+
if __name__ == '__main__':
27+
main()

2025-01-January-LeetCoding-Challenge/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
| January 8 | [3042. Count Prefix and Suffix Pairs I](https://leetcode.com/problems/count-prefix-and-suffix-pairs-i/) | Easy | Solved |
1414
| January 9 | [2185. Counting Words With a Given Prefix](https://leetcode.com/problems/counting-words-with-a-given-prefix/) | Easy | Solved |
1515
| January 10 | [916. Word Subsets](https://leetcode.com/problems/word-subsets/) | Medium | Solved |
16-
| January 11 | []() | | |
16+
| January 11 | [1400. Construct K Palindrome Strings](https://leetcode.com/problems/construct-k-palindrome-strings/) | Medium | Solved |
1717
| January 12 | []() | | |
1818
| January 13 | []() | | |
1919
| January 14 | []() | | |
@@ -40,5 +40,5 @@
4040
| Level | Problems | Solved | Unsolved |
4141
| --- | --- | --- | --- |
4242
| Easy | 4 | 4 | 0 |
43-
| Medium | 6 | 6 | 0 |
43+
| Medium | 7 | 7 | 0 |
4444
| Hard | 0 | 0 | 0 |

0 commit comments

Comments
 (0)