Group Anagrams

Given an array of strings *strs*, group the anagrams together. You can return the answer in any order. An **anagram** is a word formed by rearranging the letters of another word.

Input Format

strs = [array of strings]

Output Format

List<List<String>> (groups of anagrams)

Constraints

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

Examples

Example 1:

Input:

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

Output:

[[ate,eat,tea],[bat],[nat,tan]]

Explanation:

Anagrams are grouped together; order of groups or words within groups can vary.

Example 2:

Input:

strs = [""]

Output:

[[]]

Explanation:

Single empty string forms one group.

Loading...
Group Anagrams - Hashing DSA Problem