cheetcode

4. Group AnagramsMedium

Group words that contain the same letters into shared buckets.

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

Words are anagrams if they contain the same letters with the same counts, possibly in a different order.

You may return the groups in any order.

Examples

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

Constraints

  • 1 <= strs.length <= 10,000
  • 0 <= strs[i].length <= 100
  • strs[i] consists of lowercase English letters.