FastPrepGroup Anagrams
Problems/Group Anagrams

Group Anagrams

Vanguard logoVanguard● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names Group Anagrams without its full statement. The alphabet, the limits, what happens with empty input, and a fixed group order are our assumptions. Our version is about 70% the same as the reported question.

Given an array of strings words, group words that are anagrams. Two words are anagrams when one can be rearranged into the other, using every character exactly once.

Return the groups in the order that their first member appears in words. Preserve input order within each group. Keep duplicate words as separate entries. Empty strings are valid and belong to the same group.

Function

groupAnagrams(words: String[]) → List<List<String>>

Examples

Example 1

words = ["eat","tea","tan","ate","nat","bat"]return = [["eat","tea","ate"],["tan","nat"],["bat"]]

The first anagram families appear with eat, tan, then bat; words stay in their original order within each family.

Example 2

words = ["","a","","a"]return = [["",""],["a","a"]]

Both empty strings share the first group. Both copies of a remain in the second group.

Constraints

  • 0 <= words.length <= 10^4.
  • 0 <= words[i].length <= 100.
  • The total number of characters is at most 2 × 10^5.
  • Every word contains only lowercase English letters from a through z.

More Vanguard Online Assessment questions

  • Two SumOA · Seen Sep 2026
  • Valid ParenthesesOA · Seen Sep 2026
  • Are They PangramsOA · Seen Nov 2025
  • Missing WordsOA · Seen Nov 2025
  • Spam DetectionOA · Seen Nov 2025
  • Binge WatchingOA · Seen Jan 2023
  • Minimum Moves Around a Circular ArrayOA · Seen Aug 2022
  • Maximum Occurring CharacterOA · Seen Mar 2022
  • Picking TicketsOA · Seen Mar 2022
  • Tool List: Two Smallest ValuesOA · Seen Nov 2021

Similar questions at other companies

  • Password Clues and the Next CommandOpenAI · OAOpenAI interview questions
  • Decode Words with Anagram KeysCresta · OACresta interview questions
  • Count One-Swap Number PairsCapital One · OACapital One interview questions
  • Parcel Event TrackingAirbnb · OAAirbnb interview questions
  • Maximum Valid Substring FrequencyMicrosoft · OAMicrosoft interview questions
  • Perfect SubstringAXQ Capital · OA
  • Longest Distinct StringSuperhuman · OASuperhuman interview questions
  • Longest String ChainVisa · OAVisa interview questions
  • Longest Substring Without Repeating CharactersAkuna Capital · OAAkuna Capital interview questions
  • How Many Sentences?Chubb · OAChubb interview questions

Interview reports that mention this question

  • Vanguard Tech and Risk Older OAs: 12 Experiences (Part 3 of 3)
  • Vanguard Software Older Rounds: 13 Experiences (Part 2 of 3)
  • Vanguard Tech Intern Interviews: 37 Experiences (Part 1 of 3)
All Vanguard interview questionsSee Vanguard hiring insights
Saved
class Solution {
    public List<List<String>> groupAnagrams(String[] words) {
        // Write your code here.
    }
}
Checking account…