Updating exercises

This commit is contained in:
Carlos
2025-07-14 10:09:13 -04:00
parent 57956bf728
commit 7f1381ae93
25 changed files with 634 additions and 13 deletions

View File

@@ -0,0 +1,18 @@
// @leet start
/**
* @param {string[]} strs
* @return {string[][]}
*/
var groupAnagrams = function(strs) {
if (strs.length < 2) return [strs];
const map = {};
for (const str of strs) {
const key = str.split("").sort().join("");
if (!map[key]) {
map[key] = [];
}
map[key].push(str);
}
return Object.values(map);
};
// @leet end