Skip to content

Commit

Permalink
add (leetcode 49): js 풀이
Browse files Browse the repository at this point in the history
  • Loading branch information
padosum committed May 24, 2022
1 parent b137cb4 commit 5b0ff47
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions leetcode/medium/49-group-anagrams.js
@@ -0,0 +1,13 @@
/**
* @param {string[]} strs
* @return {string[][]}
*/
var groupAnagrams = function(strs) {
const result = {}
strs.forEach((str, idx) => {
const current = str.split("").sort().join('')
result[current] ? result[current].push(str) : (result[current] = [str])
})

return Object.values(result)
};

0 comments on commit 5b0ff47

Please sign in to comment.