Group Anagrams

Medium · Arrays & Hashing · Hash Table · String · Sorting

Problem

Given an array of strings strs, group the anagrams together. Return the groups in any order, and the strings inside each group in any order.

Examples

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

Any ordering of the groups, or within a group, is accepted.

Input: strs = [""]
Output: [[""]]

Constraints

Approaches

Related problems

Start free on Cariara · Coding problems · System design studio

Starting Python
No results yet.

          
↑↓ move ↵ open esc close

Labs

Loading labs…

Run with your own input

Starting Python

Loading Python…