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"]]
JavaScript•UTF-8
Run your code to see results.
Click the Run button above
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.