Deviopath › JavaScript

Group Anagrams

Medium · Strings

Write a function groupAnagrams that groups words that are anagrams of each other (same letters, any order).

Return an array of groups. Inside a group, keep the words in their original order (duplicates stay). Order the groups by where their first word appears in the input.

Next: Top K Frequent Words