Group Anagrams
Updated
Problem statement
Given an array of lowercase strings words, group together strings that are anagrams of one another.
For deterministic judging, sort the strings inside each group lexicographically, then sort the groups lexicographically by their full contents.
Function
groupAnagrams(words: String[]) → List<List<String>>Examples
Example 1
words = ["eat","tea","tan","ate","nat","bat"]return = [["ate","eat","tea"],["bat"],["nat","tan"]]Each group contains exactly the words with the same character multiset.
Example 2
words = [""]return = [[""]]The empty string forms one group.
Constraints
1 <= words.length <= 10000.0 <= words[i].length <= 100.- Every word contains lowercase English letters.
Source note: Author-written prompt excerpt retained for source fidelity.
More EPAM Phone Screen questions
- Longest Palindromic SubstringPHONE SCREEN · Seen Oct 2026
- Container With Most WaterPHONE SCREEN · Seen Oct 2026
- Convert an Entry List to a MapPHONE SCREEN · Seen Oct 2026
- Count Array Element FrequenciesPHONE SCREEN · Seen Oct 2026
- Find First and Last Position of Element in Sorted ArrayPHONE SCREEN · Seen Oct 2026
- Longest Consecutive SequencePHONE SCREEN · Seen Oct 2026
- Max Consecutive Ones IIIPHONE SCREEN · Seen Oct 2026
- Minimum Currency ConversionsPHONE SCREEN · Seen Oct 2026
- Next Greater Element IPHONE SCREEN · Seen Oct 2026
- Partition and Group Values by ParityPHONE SCREEN · Seen Oct 2026
Similar questions at other companies
- Group AnagramsWorkday · PHONE SCREEN
- Find Duplicate File GroupsAnthropic · PHONE SCREENAnthropic interview questions
- Insert an Employee into an Organization HierarchyWaymo · PHONE SCREENWaymo interview questions
- Group AnagramsMotive · PHONE SCREEN · ONSITE INTERVIEWMotive interview questions
- Stable Top K Frequent WordsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Group AnagramsBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Find Duplicate Image FilesAbnormal Security · PHONE SCREEN
- Shared Courses for Each Pair of StudentsWhatNot · PHONE SCREENWhatNot interview questions
- Credit Card Command ProcessorChime · PHONE SCREEN
- Employee Salary Report by GroupRippling · PHONE SCREENRippling interview questions