Group Anagrams

Group an array of strings so that each group contains anagrams of each other (order of groups doesn’t matter).

Input Format

First line n, then n words.

Output Format

List of groups (in any order).

Constraints

  • Total chars <= 10^5.

Examples

Example 1:

Input:

strs = ["eat","tea","tan"]

Output:

[[eat,tea],[tan]]

Explanation:

"eat" and "tea" are anagrams.

Loading...
Group Anagrams - Strings DSA Problem