C16/Cedar- Ana Gabriele #39
Conversation
chimerror
left a comment
There was a problem hiding this comment.
Good work!
I left some comments about your time complexity calculation for the anagrams problems, and a few comments about extraneous testing code left in. Otherwise, though, this looks good enough for a Green, so that's what I'm giving it!
| Time Complexity: ? | ||
| Space Complexity: ? | ||
|
|
||
| Time Complexity: O(m * nlogn) - | python sorting algorithm -> O(n. logn). |
There was a problem hiding this comment.
While this is an accurate answer assuming n stands for the number of characters in the strings and m stands for the number of strings in the list, we can make a simplifying assumption. Since we know the strings are English words, we can be pretty sure they will not get too big in size. On average words in English have about 5 letters, which is going to very quickly get dwarfed by the number of words in the list so we can simply say this is O(m) in time complexity.
| return list(hash_table.values()) | ||
|
|
||
|
|
||
| print(grouped_anagrams(["eat", "tae", "tea", "eta", "aet", "ate"])) |
There was a problem hiding this comment.
In general, make sure to remove testing code like this before you submit your PRs.
| if len(result) == k: | ||
| return result | ||
|
|
||
| print(top_k_frequent_elements([9,9,8,8,7],2)) |
There was a problem hiding this comment.
Same thing as above, make sure to remove testing code like this. It helps keep the code cleaner which is good style.
Hash Table Practice
Congratulations! You're submitting your assignment!
Comprehension Questions