-
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
Leaves - Mariya #38
base: master
Are you sure you want to change the base?
Leaves - Mariya #38
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 hit the main learning goals here. Take a look at my inline comments and let me know what questions you have. Well done.
# Time Complexity: O(n) | ||
# Space Complexity: O(n) | ||
|
||
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 works and assuming the words are small you are right on the time/space complexity.
end | ||
end | ||
|
||
values_sort = counter_hash.sort_by {|key, value| -value} |
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 sort depends on the number of distinct elements, so it's worst-case O(n log n)
# Time Complexity: O(n) | ||
# 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, but take a look at my comments on big O.
Hash Table Practice
Congratulations! You're submitting your assignment!
Comprehension Questions