Group Anagrams

Problem Given an array of strings, group together all strings that are anagrams of one another.

Input / Output

  • Input: array of strings strs.
  • Output: a list of groups, each containing strings that are anagrams of each other (order within and among groups doesn't matter).

Constraints

  • 1 ≤ n ≤ 10^4; strings consist of lowercase English letters.
  • Total input length can be large, so per-string work should stay near-linear.

Example

  • ["eat","tea","tan","ate","nat","bat"] → [["eat","tea","ate"],["tan","nat"],["bat"]]
added …
LeaderboardSalaryAccount