-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Daniela - Leaves #36
base: master
Are you sure you want to change the base?
Daniela - Leaves #36
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You didn't attempt the comprehension questions!
You did get grouped_anagrams
method working. Take a look at my comments about bigO for my comments there. Missing kth most frequent elements, but what you have is well done.
lib/exercises.rb
Outdated
# Time Complexity: n^2 as for each word in the list I'm iterating over the letters. | ||
|
||
# # Space Complexity: O(n) because if none of the words are anagrams, | ||
# I will duplicate the array. Also, I will create a hash were each key is each word. | ||
|
||
|
||
def grouped_anagrams(strings) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually O(n * m) where m is the length of the strings. Or O(n) if the words are limited in size.
Good use of a hash as a key to another hash!
@CheezItMan I just submitted my second exercise. Can you review it when you have a chance? I would appreciate your feedback. TY!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work Daniela, these both work. Well done.
end | ||
# Time Complexity: O(kn) | ||
# Space Complexity: O(n) | ||
def top_k_frequent_elements(list, k) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works
# Time Complexity: O(n * m) as for each word in the list I'm iterating over the letters. | ||
# # Space Complexity: O(n). | ||
|
||
def grouped_anagrams(strings) | ||
raise NotImplementedError, "Method hasn't been implemented yet!" | ||
def grouped_anagrams(list_strings) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Nice work!
Hash Table Practice
Congratulations! You're submitting your assignment!
Comprehension Questions