DSA · Hashing / grouping · #11
Group Anagrams
Module 14 · difficulty 3/5·⏱ 30:00starts on first keystroke
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 another, using all the original letters exactly once.
Examples
strs = ["eat","tea","tan","ate","nat","bat"]→[["bat"],["nat","tan"],["ate","eat","tea"]]strs = [""]→[[""]]strs = ["a"]→[["a"]]
Stuck? Reveal an animated walkthrough of the approach.
Constraints
- · 1 <= strs.length <= 10^4
- · 0 <= strs[i].length <= 100
- · strs[i] consists of lowercase English letters.
Session phases
A · Clarify
B · Approach
C · Complexity
D · Edges
E · Code
F · Tradeoff
G · Score
Phase A — Clarify
Ask questions about input bounds, types, and edge constraints.
Ask the coach clarifying questions about the problem.
When you've covered this phase, advance to the next.