# 49. Group Anagrams

Reference: LeetCode
Difficulty: Medium

## Problem

Given an array of strings, group anagrams together.

Note:

• All inputs will be in lowercase.
• The order of your output does not matter.

Example:

## Analysis

### HashMap + Sorting

Time: $O(NK\log{K})$ where $K$ is the maximum length of a string.
Space: $O(NK)$

### Categorize by Count

Count a string’s characters and generate a key like #1#2#3#4....

Time: $O(NK)$
Space: $O(NK)$

Comment
Junhao Wang
a software engineering cat