-
Notifications
You must be signed in to change notification settings - Fork 8
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
Branches- Amal #2
base: master
Are you sure you want to change the base?
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 learning goals here. Well done. Do take a look at my notes regarding time complexity and let me know if you have questions.
// Time Complexity: O(n * m) | ||
// Space Complexity: O(n) | ||
function 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.
The Time complexity would be O(n) if the words aren't too long. Or O(m * n log n) if the words are (m words and each word is at most n letters). The sort is a mergesort and it costs the most with each word.
if(listObj[a] == listObj[b]){ | ||
return -1 | ||
}else{ |
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.
Why not just subtract?
// Time Complexity: O(n) | ||
// Space Complexity: O(n) | ||
function 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.
Since you're doing a sort it's O(n log n) time complexity.
Hash Table Practice
Congratulations! You're submitting your assignment!
Comprehension Questions