From ab15af7c6f190a71f3a248e8df4c53951e0f823f Mon Sep 17 00:00:00 2001 From: Lathika11 Date: Thu, 9 Apr 2026 19:32:25 +0530 Subject: [PATCH 1/2] Added palindrome checker script --- strings/group_anagram.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 strings/group_anagram.py diff --git a/strings/group_anagram.py b/strings/group_anagram.py new file mode 100644 index 000000000000..1a2e2d1ca2dd --- /dev/null +++ b/strings/group_anagram.py @@ -0,0 +1,16 @@ +def group_anagrams(strs:list[str]) -> list[list[str]]: + """ Group word that are anagrams. + Two words are anagram if they contain the same + character in a different order. + :param words: List of input strings + :return :List of grouped anagrams + """ + res={} + for word in strs: + key="".join(sorted(word)) #fixed key + if key not in res: + res[key]=[] + res(key.append(word)) #fixed syntax + return list(res.values()) #fixed function call +if __name__ == "__main__" +print(group_anagrams["eat","tea","tan","ate","nat","bat"]) \ No newline at end of file From 33982774d4389d7b6d21a64ef4d27785bb7897d4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 9 Apr 2026 14:10:44 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- strings/group_anagram.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings/group_anagram.py b/strings/group_anagram.py index 1a2e2d1ca2dd..6787507526c6 100644 --- a/strings/group_anagram.py +++ b/strings/group_anagram.py @@ -13,4 +13,4 @@ def group_anagrams(strs:list[str]) -> list[list[str]]: res(key.append(word)) #fixed syntax return list(res.values()) #fixed function call if __name__ == "__main__" -print(group_anagrams["eat","tea","tan","ate","nat","bat"]) \ No newline at end of file +print(group_anagrams["eat","tea","tan","ate","nat","bat"])