Skip to content

Commit 736e8f0

Browse files
committed
added comments on complexity
1 parent 776a4b3 commit 736e8f0

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

‎Sprint-2/improve_with_precomputing/common_prefix/common_prefix.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ def find_longest_common_prefix(strings: List[str]):
66
find_longest_common_prefix returns the longest string common at the start of any two strings in the passed list.
77
88
In the event that an empty list, a list containing one string, or a list of strings with no common prefixes is passed, the empty string will be returned.
9+
10+
Before changes: O(N^2 * avg(string_length)) - each string compared with each other string in double loop.
11+
After changes: O(N * logN * avg(string_length))
12+
913
"""
1014
if len(strings) <= 1:
1115
return ""

‎Sprint-2/improve_with_precomputing/count_letters/count_letters.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
def count_letters(s: str) -> int:
22
"""
33
count_letters returns the number of letters which only occur in upper case in the passed string.
4+
5+
Before changes: O(N^2) - each letter compared with each other in double loop.
6+
After changes: O(N + min(len(set_upper), min(len(set_lower)))
7+
48
"""
59
appeared_upper = set()
610
appeared_lower = set()

0 commit comments

Comments
 (0)