Hack Frontend Community

Group Anagrams

VKTinkoffMail.ru
Write a function groupAnagrams(arr) that takes an array of strings arr and groups anagrams together. Conditions:
  • An anagram is a word or phrase formed by rearranging the letters of another word or phrase (e.g., "tea" => "eat").

Examples:

Input 1: ["ab", "ba", "abc", "bca"]
Output 1: [["abc","bca"],["ab","ba"]]
Input 2: ["listen", "silent", "enlist"]
Output 2: [["listen","silent","enlist"]]
Run your code to see results.