You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Your solution for Group Anagrams is well thought out and uses the prime number hashing technique correctly. The code is clean and readable. However, there are a few points to note:
In Python, it is better to return a list of the dictionary values explicitly. Instead of return d.values(), use return list(d.values()) to ensure compatibility with Python 3 and to meet the problem's requirement of returning a list of lists.
Although not necessary for the given constraints, be aware that for very long strings the product of primes might become very large. However, in Python integers can handle this without overflow, so it is acceptable.
You might consider adding a comment about why you chose primes and how the hashing works, but the code is clear enough.
The solution for Isomorphic Strings was included in the same file? Actually, the student provided two separate files. But in the submission, it seems like they are both in the same response. For the purpose of this problem, we are only evaluating Group Anagrams. Make sure to submit only the required solution.
For the empty string, your code works correctly because the hash for an empty string is 1.
Overall, great job! Just remember to return a list explicitly.
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
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.
No description provided.