FastPrepGroup Anagrams
Problems/Group Anagrams

Group Anagrams

Microsoft logoMicrosoft● MediumNEW GRADINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Microsoft Software Engineer IC2 interview report named Group Anagrams. The report did not include the function signature, examples, limits or output order, so we state those usual details here. Our version is about 90% the same as the reported question.

Group the strings in strs so that two strings appear in the same group exactly when they are anagrams.

Sort the strings inside each group lexicographically. Then sort the groups lexicographically by their complete arrays.

Function

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

Examples

Example 1

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

Example 2

strs = [""]return = [[""]]

Constraints

  • 1 <= strs.length <= 10^4
  • 0 <= strs[i].length <= 100
  • Every string contains only lowercase English letters.
  • The total number of characters is at most 10^5.

More Microsoft Onsite Interview questions

  • Bad Request AlertsONSITE INTERVIEW · Seen Nov 2026
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
  • Valid ParenthesesONSITE INTERVIEW · Seen Nov 2026
  • Count a User's Actions in an Event LogONSITE INTERVIEW · Seen Nov 2026
  • Smallest Batch Size Within a Step LimitONSITE INTERVIEW · Seen Nov 2026
  • Count Subarrays with Equal Even and Odd CountsONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Rot All OrangesONSITE INTERVIEW · Seen Nov 2026
  • Coin ChangeONSITE INTERVIEW · Seen Oct 2026
  • Daily USD Totals with Effective-Dated Exchange RatesONSITE INTERVIEW · Seen Oct 2026
  • Number Words to Digits in Any LanguageONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Group AnagramsAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
  • Longest Consecutive Login StreakAmazon · ONSITE INTERVIEW
  • Find Duplicate Element PairsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Deep Merge with a Conflict ResolverAutodesk · ONSITE INTERVIEWAutodesk interview questions
  • Group Duplicate Files by ContentPostman · ONSITE INTERVIEWPostman interview questions
  • Group AnagramsGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
  • Group AnagramsMotive · PHONE SCREEN · ONSITE INTERVIEWMotive interview questions
  • Group AnagramsBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Group AnagramsExpedia · ONSITE INTERVIEWExpedia interview questions
  • Group AnagramsAkuna Capital · ONSITE INTERVIEWAkuna Capital interview questions

Interview reports that mention this question

  • Microsoft SWE Intern Interviews: 244 Experiences (Part 1 of 6)

Microsoft interview experiences

  • Microsoft OA Questions, October 2026: 4 Experiences
  • Microsoft Experienced SWE Phone Screen: 1 Experience
  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public List<List<String>> groupAnagrams(String[] strs) {
      // write your code here
    }
}
Checking account…