O15
Group Anagrams
Problem Statement & Objective
Given an array of strings, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
Function Signature (Python)
group_anagrams(words: list[str]) -> list[list[str]]Input & Output Contract
Output Rule:List of lists of grouped strings.
System Constraints
1 <= kelimeler.length <= 10^4
0 <= kelimeler[i].length <= 100
strings consist of lowercase English lettersExample Execution Walkthrough
kelimeler = ["eat","tea","tan","ate","nat","bat"]
result: [["bat"],["nat","tan"],["ate","eat","tea"]]Example Test Scenarios (3)
Example 1
Input:
[["eat","tea","tan","ate","nat","bat"]]Expected Output:
[["ate","eat","tea"],["bat"],["nat","tan"]]Example 2: Boş Kelime
Input:
[[""]]Expected Output:
[[""]]Example 3: Tek Harf
Input:
[["a"]]Expected Output:
[["a"]]