Group Anagrams

Write the code, see it run, pass the checks.

The problem

  • medium
  • Code

Write groupAnagrams(words): put words that are anagrams of each other (exactly the same letters, in another order) in the same group. Groups come in the order their first word appears, and words keep their order within a group: ["eat", "tea", "tan", "ate", "nat", "bat"] gives [["eat", "tea", "ate"], ["tan", "nat"], ["bat"]].

Your code must pass

  • Groups anagrams together
  • Keeps the order words came in
  • Tells apart words with the same letters in different amounts
  • Returns an empty list for no words