Skip to content

Practice Group Anagrams

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#49
LeetCode Problem

Group Anagrams

Problem Statement

Given an array of strings strs, group the anagrams together. You can return the answer in any order.

Source: Group Anagrams on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
strs = ["eat","tea","tan","ate","nat","bat"]
Output
[["bat"],["nat","tan"],["ate","eat","tea"]]

# Example 2

Input
strs = [""]
Output
[[""]]

# Example 3

Input
strs = ["a"]
Output
[["a"]]

Constraints

1 <= strs.length <= 10^4
0 <= strs[i].length <= 100
strs[i] consists of lowercase English letters.

Related LeetCode Problems

Practice more problems similar to Group Anagrams.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.