Skip to content

Commit 5187863

Browse files
committed
collect all lowercase letters present in s string into a set beforehand
1 parent 237d8bc commit 5187863

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

Sprint-2/improve_with_precomputing/count_letters/count_letters.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
def count_letters(s: str) -> int:
2-
"""
3-
count_letters returns the number of letters which only occur in upper case in the passed string.
4-
"""
2+
only_lower = set()
3+
for letter in s:
4+
if letter.islower():
5+
only_lower.add(letter)
6+
7+
8+
59
only_upper = set()
610
for letter in s:
711
if is_upper_case(letter):

0 commit comments

Comments
 (0)