Group Anagrams
Medium
strings
Google
Meta
Given a list of strings, group the anagrams together. An anagram is a word formed by rearranging the letters of another word.
Return a list of groups (each group is a sorted list of strings). The groups themselves should be sorted by their first element.
Example:
Input: ["eat", "tea", "tan", "ate", "nat", "bat"]
Output: [["ate", "eat", "tea"], ["bat"], ["nat", "tan"]]
Test Cases
Python Editor
Output
Click "Run" to see results...