mediumArrayHash TableSortingString 0 views

Group Anagrams

Given an array of strings strs, group the anagrams together.

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

Group Anagrams diagram

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.

Hints

No hints yet.

Companies

No companies reported yet.

Discussion

Sign in to join the discussion.

Loading discussion...

Test results

No test cases yet.