Conversation
kyra-patton
left a comment
There was a problem hiding this comment.
✨ Nice work, Kayla. I left some comments on time and space complexity. See Github for details.
🟢
| Each subarray will have strings which are anagrams of each other | ||
| Time Complexity: ? | ||
| Space Complexity: ? | ||
| Time Complexity: O(n^2)? The fucntion only loops through the length of strings for |
There was a problem hiding this comment.
⏱ Sorting is an O(n) operation, however if we assume all strings are valid english words, we can say this is an O(1) operation because n will never be very large.
Therefore you just have the for loop through the elements of strings which would make this O(n)
| Space Complexity: ? | ||
| Time Complexity: O(n^2)? The fucntion only loops through the length of strings for | ||
| the number of letters in each string? | ||
| Space Complexity: O(n)? Theres only 2 varaibles being stored...sortedWord and anagramsHash? |
There was a problem hiding this comment.
🪐 Yes! anagramsHash can have at most n elements where n is the length of strings. Overall the combined length of the values will also be n elements.
| Time Complexity: ? | ||
| Space Complexity: ? | ||
| Time Complexity: O(n) | ||
| Space Complexity: O(n^2)? |
There was a problem hiding this comment.
Space complexity would be O(n). finalList will be of length k which can never be greater than the length of nums. freqHash will have at most n key value pairs as well, where the values are all integers.
Hash Table Practice
Congratulations! You're submitting your assignment!
Comprehension Questions