-
Notifications
You must be signed in to change notification settings - Fork 39
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
Earth - Christina Minh #23
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.
Nice work Christina. You hit the main learning goals here. I had a few comments on big O regarding the 2nd method, but otherwise this is well done. You even got the Sudoku problem. Well done.
# Time Complexity: O(n * m * log m) | ||
# where n is the number of strings in the array to iterate over, | ||
# and m is the number of characters to sort in a string (m log m), | ||
# Space Complexity: O(n * m) from sorting characters (m) and returning a new array (n) | ||
# where n is the number of strings in the array | ||
# and m is the number of characters in a string | ||
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.
👍
# Time Complexity: O(n + m log m) where n is the number of elements in the list and | ||
# and m is the number of unique elements to sort (m log m) | ||
# Space Complexity: O(m * k) where m is the number of unique elements to put in hash | ||
# and k is the number of elements to return | ||
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.
👍 I would say this is O(n log n) since k < n, and you're potentially sorting a hash of n elements.
For space complexity since k < n, and you make a hash of potentially n elements this is O(n).
# Time Complexity: O(1) constant time to iterate over table that is always 9x9 | ||
# Space Complexity: O(1) | ||
def valid_sudoku(table) |
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.
👍 Nicely done.
Hash Table Practice
Congratulations! You're submitting your assignment!
Comprehension Questions