Skip to content

Commit dc47abb

Browse files
committed
update the 2nd loop to check agaisnt the pre-calcualted lowercase letters set instead of s string
1 parent 5187863 commit dc47abb

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

Sprint-2/improve_with_precomputing/count_letters/count_letters.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ def count_letters(s: str) -> int:
44
if letter.islower():
55
only_lower.add(letter)
66

7-
8-
97
only_upper = set()
108
for letter in s:
119
if is_upper_case(letter):
12-
if letter.lower() not in s:
10+
if letter.lower() not in only_lower:
1311
only_upper.add(letter)
1412
return len(only_upper)
1513

0 commit comments

Comments
 (0)