-
Notifications
You must be signed in to change notification settings - Fork 40
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
Tatiana #18
base: master
Are you sure you want to change the base?
Tatiana #18
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.
Nice work, you hit the learning goals here. Excellent work! Thanks for getting this in.
# Time Complexity: O(n) it must go through the entire list | ||
# Space Complexity: O(n) we return an array of size n same as the input array |
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.
👍
return_array.push(sorted_hash_array[i][0]) | ||
i += 1 |
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.
indentation
end | ||
|
||
# This method will return the k most common elements | ||
# in the case of a tie it will select the first occuring element. | ||
# Time Complexity: ? | ||
# Space Complexity: ? | ||
# Time Complexity: O(nLogn) |
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.
where n
is the number of distinct elements.
You also should consider that the list might be much longer than the number of distinct elements.
So maybe O(n + k log k) where k
is the number of distinct elements and n the number of elements.
Hash Table Practice
Congratulations! You're submitting your assignment!
Comprehension Questions