Open
Conversation
…sts to match changes from Matt.
…icated about Big-O notation and the most efficient solution.
CheezItMan
reviewed
Sep 17, 2019
CheezItMan
left a comment
There was a problem hiding this comment.
Nice work, you hit the learning goal of this exercise. Well done.
| }); | ||
|
|
||
| describe.skip("valid sudoku", function() { | ||
| it("is not valid if a row has duplicate values", function() { |
| function grouped_anagrams(strings) { | ||
| throw new Error("Method hasn't been implemented yet!"); | ||
| // Time Complexity: O(n) where n is the length of the array passed in as the argument "strings" because each item in the array is visited once | ||
| // Space Complexity: O(1) (***Chris, is this right? It takes 2 times the space of 'strings' which reduces to 1. Or is it O(n) because the space taken is is 2 x n where n is the length of the 'strings' array?***) |
There was a problem hiding this comment.
I would say O(n) because you are building a JavaScript object which scales based on the size of the array.
|
|
||
| strings.forEach(str => { | ||
| let tempStr = str.split('').sort().join(''); // alphabetize str | ||
| anagrams[tempStr] ? anagrams[tempStr].push(str) : anagrams[tempStr] = [str]; |
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