Open
Conversation
CheezItMan
reviewed
Sep 18, 2019
CheezItMan
left a comment
There was a problem hiding this comment.
You have both methods working. Nice job! See my notes on the time complexity.
Well done!
| # Each subarray will have strings which are anagrams of each other | ||
| # Time Complexity: ? | ||
| # Space Complexity: ? | ||
| # Time Complexity: Would this by O(nlog n) for sorting of the string? |
There was a problem hiding this comment.
I would say O( n * m log m) where n is the number of words, and m the length of each word. If you can assume that the words are small, then you could say this is O(n)
| # Time Complexity: ? | ||
| # Space Complexity: ? | ||
| # Time Complexity: Would this by O(nlog n) for sorting of the string? | ||
| # Space Complexity: O(n + m), n is the size of the array and m is the size of the hash |
There was a problem hiding this comment.
Since the size of the hash depends on the size of strings I would say O(n)
| # in the case of a tie it will select the first occuring element. | ||
| # Time Complexity: ? | ||
| # Space Complexity: ? | ||
| # Time Complexity: O(nlog n) because of the sorted array is at least |
There was a problem hiding this comment.
True! Could this be faster without sorting?
| sorted_frequencies = freq_hash.values.sort | ||
|
|
||
| answer_arr = [] | ||
| k.times do |
There was a problem hiding this comment.
This looks like a loop that runs k times and a nested loop which runs maybe n times.
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