Group Anagrams

MediumHashMap

Description

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 a different word, using all the original letters exactly once.

Examples

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

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

Input: strs = [""]

Output: [[""]]

Input: strs = ["a"]

Output: [["a"]]

Constraints

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

Your Solution

JavaScript·3 test cases·Max 5,000 chars · 2s timeout · 10 runs/30s
Loading...