-
Notifications
You must be signed in to change notification settings - Fork 41
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
Space - Cathy #14
base: master
Are you sure you want to change the base?
Space - Cathy #14
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 Cathy, you hit the learning goals here. I like your documentation and especially how you implemented top_k_frequent_elements
. Well done.
lib/exercises.rb
Outdated
# Time Complexity: O(n^2) where n is the number of strings? || O(n) where n is the total number of characters? | ||
# Space Complexity: O(n) where a new hash is storing the n # of strings | ||
|
||
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.
👍 But your time complexity is O(n) since you're only looping through the words once.
# Time Complexity: O(nlogn) since I'm calling a sort_by enumerable | ||
# 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.
Nice work, good job looking up what max_by does. Well done.
lib/exercises.rb
Outdated
# Reference: https://www.tutorialspoint.com/valid-sudoku-in-python | ||
# Time Complexity: O(n^2) where n is the length of the input table and since table is a 2d array | ||
# Space Complexity: O(1) where the extra hashes are constant tracking 1~9 | ||
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.
👍 Actually since a Sudoku board is always 9x9, scaling never changes so it's O(1) instead of O(n^2)
# Thought I could use a hash function to solve grouped_anagrams, but realized the sum/math would cause incorrect results | ||
# 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.
🥇
Hash Table Practice
Congratulations! You're submitting your assignment!
Comprehension Questions