Skip to content

Commit ab15af7

Browse files
committed
Added palindrome checker script
1 parent 02680c9 commit ab15af7

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

strings/group_anagram.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
def group_anagrams(strs:list[str]) -> list[list[str]]:
2+
""" Group word that are anagrams.
3+
Two words are anagram if they contain the same
4+
character in a different order.
5+
:param words: List of input strings
6+
:return :List of grouped anagrams
7+
"""
8+
res={}
9+
for word in strs:
10+
key="".join(sorted(word)) #fixed key
11+
if key not in res:
12+
res[key]=[]
13+
res(key.append(word)) #fixed syntax
14+
return list(res.values()) #fixed function call
15+
if __name__ == "__main__"
16+
print(group_anagrams["eat","tea","tan","ate","nat","bat"])

0 commit comments

Comments
 (0)