File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed
2025-01-January-LeetCoding-Challenge Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 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 ()
Original file line number Diff line number Diff line change 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 | [ ] ( ) | | |
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 |
You can’t perform that action at this time.
0 commit comments