Problem
You get an array of strings strs. Put the strings into groups, so that each group contains only anagrams of each other.
Two strings are anagrams when they contain the same characters the same number of times. The order of the characters can be different. For example, "night" and "thing" are anagrams.
Return a list of the groups. You can return the groups in any order, and the strings in each group in any order.
Example 1
- Input:
- strs = ["pots","stop","cat","tops","act","dog"]
- Output:
- [["pots","stop","tops"],["cat","act"],["dog"]]
- Explanation:
- The strings
"pots","stop"and"tops"use the same letters. The string"dog"has no anagram in the list, so it is a group of one.
Example 2
- Input:
- strs = ["","b",""]
- Output:
- [["",""],["b"]]
- Explanation:
- The two empty strings are anagrams of each other.
Example 3
- Input:
- strs = ["abc","bca","cab","xyz"]
- Output:
- [["abc","bca","cab"],["xyz"]]
Constraints
- 1 <= strs.length <= 10^4
- 0 <= strs[i].length <= 100
- strs[i] contains only lowercase English letters.
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Accounts Merge
Coding · Array · Breadth-First Search · Depth-First Search
- Analyze User Website Visit Pattern
Coding · Array · Hash Table · Sorting
- Rank Teams by Votes
Coding · Array · Counting · Hash Table
- Reward Top K Students
Coding · Array · Hash Table · Heap (Priority Queue)
Sources · 2 references
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 12 records
Amazon
Leetcode 49. Group Anagrams
Reported Mar 20, 2025 · 2 source reports
JUNIOR, MID_LEVEL
Source snapshot: Nov 12, 2026
View sourceArize Ai
Leetcode 49. Group Anagrams
Reported Jul 9, 2026 · 1 source report
SENIOR
Source snapshot: Nov 12, 2026
View sourceExpedia
Leetcode 49. Group Anagrams
Reported Jun 10, 2026 · 2 source reports
MID_LEVEL
Source snapshot: Nov 12, 2026
View sourceFreelancer
Leetcode 49. Group Anagrams
Reported Jun 25, 2025 · 1 source report
STAFF
Source snapshot: Nov 12, 2026
View source