Completed Hashing1#2289
Conversation
Grouping Anagrams Together (group-anagrams.py)Your solution is correct and well-explained. You have accurately analyzed the time and space complexity. However, there are a few points to improve:
Overall, your solution is good and passes all test cases, but with the noted improvements, it could be more efficient. VERDICT: PASS Isomorphic Strings (isomorphic-strings.py)Your solution has the right idea by using two dictionaries to track the mappings in both directions. However, there are several issues that need to be fixed:
Here is a corrected version of your code: def isIsomorphic(s, t):
if len(s) != len(t):
return False
smap = {}
tmap = {}
for i in range(len(s)):
schar = s[i]
tchar = t[i]
if schar in smap:
if smap[schar] != tchar:
return False
else:
smap[schar] = tchar
if tchar in tmap:
if tmap[tchar] != schar:
return False
else:
tmap[tchar] = schar
return TrueYour approach is correct in logic, but the indentation error would prevent it from running. Also, the initial check was misguided. Keep up the good work in thinking about bidirectional mapping! VERDICT: NEEDS_IMPROVEMENT Word Pattern (word-pattern.py)Your solution is well-structured and correctly solves the problem. You have correctly implemented the bijection check using a dictionary for pattern->word mapping and a set to ensure words are not reused. The code is readable with clear variable names. Strengths:
Areas for improvement:
Overall, your solution is correct and efficient. VERDICT: PASS |
No description provided.