-
Notifications
You must be signed in to change notification settings - Fork 9
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
Aimee 👾 - Fire 🔥 #1
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.
Well done Aimee, you hit the learning goals here. Nice work!
// Time Complexity: O(n^3) - outer while loop (line 10) has a nested for loop (lines 24 and 27), it also has .splice() nested in a for loop, but this should still be O(n^3) overall. | ||
// Space Complexity: O(n) - result, hash, and matched will be at most length n, where n is the number of elements in the strings array. Even though result is a nested array, it will never contain more than n elements. | ||
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.
Suggestion: Sort the letters in each word and use that as a key to a hash and make the value a list of words with those letters.
// Time Complexity: O(nlog(n)) - uses javascript sort, where n is the unique number of elements (worst case) | ||
// Space Complexity: O(n) - the hash object will never have more than n number of key-value pairs (based on what elements are in list), and the result array will never have more than n elements, where n is the value of k | ||
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.
👍 This will work
// Time Complexity: O(n) | ||
// Space Complexity: O(n) | ||
function 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.
👍 Fun fact, since a Sudoku board is always 9x9, this problem is actually O(1) !
Hash Table Practice
Congratulations! You're submitting your assignment!
Comprehension Questions