Given an array of strings strs, group the anagrams together. You can return the answer in any order.

Example 1:

  • Input: strs = [โ€œeatโ€,โ€teaโ€,โ€tanโ€,โ€ateโ€,โ€natโ€,โ€batโ€]
  • Output: [[โ€œbatโ€],[โ€œnatโ€,โ€tanโ€],[โ€œateโ€,โ€eatโ€,โ€teaโ€]]
  • Explanation:
  • There is no string in strs that can be rearranged to form โ€œbatโ€.
  • The strings โ€œnatโ€ and โ€œtanโ€ are anagrams as they can be rearranged to form each other.
  • The strings โ€œateโ€, โ€œeatโ€, and โ€œteaโ€ are anagrams as they can be rearranged to form each other.

Example 2:

  • Input: strs = [โ€โ€]
  • Output: [[โ€โ€]]

Example 3:

  • Input: strs = [โ€œaโ€]
  • Output: [[โ€œaโ€]]

Constraints:

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