Skip to content

Commit a7cdf3b

Browse files
committed
Use "Big O Notation" to explain why the new implmentation is more efficient than the previous one
1 parent 0b395e3 commit a7cdf3b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Sprint-2/improve_with_precomputing/count_letters/count_letters.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,14 @@ def count_letters(s: str) -> int:
1414

1515
def is_upper_case(letter: str) -> bool:
1616
return letter == letter.upper()
17+
18+
19+
20+
"""
21+
The old implementation scans through the entire string for every uppercase letter
22+
we check against, therefore complexity in the worst case is O(n^2). However, in the
23+
new implementation the lowercase letters a store beforehand in a set. This allows
24+
checking against every uppercase letter without scanning through the entire string.
25+
As a result, the complexixty time goes down to O(n) with the new implementation.
26+
27+
"""

0 commit comments

Comments
 (0)