Zero To DSAZero To DSA
Privacy Policy路FAQ路Report a Bug路Support on Ko鈥慺i
Two Sum (Optimal)Longest Consecutive Sequence

Group Anagrams

medium
Time: O(n * k log k)
Space: O(n * k)

Given an array of strings strs, group the anagrams together. An anagram is a word formed by rearranging the letters of another.

Constraints

  • 1 <= strs.length <= 10^4
  • 0 <= strs[i].length <= 100

Examples

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