Open
Conversation
CheezItMan
reviewed
Sep 15, 2020
CheezItMan
left a comment
There was a problem hiding this comment.
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
Comment on lines
4
to
7
| # 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.
👍 But your time complexity is O(n) since you're only looping through the words once.
Comment on lines
+31
to
33
| # 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.
Nice work, good job looking up what max_by does. Well done.
Comment on lines
61
to
64
| # 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.
👍 Actually since a Sudoku board is always 9x9, scaling never changes so it's O(1) instead of O(n^2)
Comment on lines
+103
to
+104
| # Thought I could use a hash function to solve grouped_anagrams, but realized the sum/math would cause incorrect results | ||
| # def grouped_anagrams(strings) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hash Table Practice
Congratulations! You're submitting your assignment!
Comprehension Questions