-
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
vi #39
base: master
Are you sure you want to change the base?
vi #39
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.
Overall nice work, you hit the main learning goals here. Well done. Do take a look at my minor comments. You did have a typo on submission in anagrams. It's helpful to run the code once prior to submission.
anagram_hash[sorted_string] = [word] | ||
end | ||
end | ||
return anagram_hash.valuesend |
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.
Missing an end
after the return
return anagram_hash.valuesend | |
return anagram_hash.values | |
end |
k.times do | ||
max = nil | ||
hash.each do |num, 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.
Just note that this iterates k times and each time loops through an hash of n size so this is O(nk)
# 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 time complexity.
Hash Table Practice
Congratulations! You're submitting your assignment!
Comprehension Questions