Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions JungHwan/NeetCode_AnagramGroups.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Solution:
def isAnagram(self, s: str, t: str) -> bool:
if(len(s) != len(t)): return False
for i in s:
if(s.count(i) != t.count(i)):
return False
return True

def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
answers = []
while(len(strs) != 0):
print(strs)
s = strs.pop(0)
answer = [s]
newList = strs[:]
for i in strs:
if Solution.isAnagram(Solution, s, i):
answer.append(i)
newList.remove(i)
strs = newList
answers.append(answer)
return answers