Skip to content

Commit 50a2ae1

Browse files
committed
don't need to count even freqs, odd is enough
1 parent d562109 commit 50a2ae1

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

Python/chapter01/1.4 - PalinPerm/miguel_1.4_sol.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,11 @@ def is_permutation_of_palindrome(word: str) -> bool:
2626
"""
2727
char_frequencies = collections.Counter(word.lower().replace(' ', ''))
2828
num_odd_freq_chars = 0
29-
num_even_freq_chars = 0
3029

3130
for key, val in char_frequencies.items():
3231
if num_odd_freq_chars > 1:
3332
return False
34-
if val % 2 == 0:
35-
num_even_freq_chars += 1
36-
else:
33+
if val % 2 != 0:
3734
num_odd_freq_chars += 1
3835
return True
3936

0 commit comments

Comments
 (0)