Dashboard
LC #49

Group Anagrams

Pattern · ?AmazonMetaGoogleMicrosoftBloomberg

Problem

Given an array of strings, group the strings that are anagrams of each other and return all groups.

Constraints

  • 1 ≤ strs.length ≤ 10⁴
  • 0 ≤ strs[i].length ≤ 100
  • strs[i] consists of lowercase English letters

Example

Input
strs = ["eat","tea","tan","ate","nat","bat"]
Output
[["bat"],["nat","tan"],["ate","eat","tea"]]
Why
eat/tea/ate share the same sorted form "aet"

Spot the pattern

Which pattern cracks it?

Hints

One at a time
Solve on LeetCode ↗