Groups of Special-Equivalent Strings LeetCode solution in JavaScript
1var numSpecialEquivGroups = function (words) {2const set = new Set();3const a = "a".charCodeAt(0);4const alphaCounter = new Array(26).fill(0);5for (const word of words) {6const [even, odd] = [[...alphaCounter], [...alphaCounter]];7word.split("").forEach((l, i) => {8l = l.charCodeAt(0) - a;9if (i % 2) odd[l]++;10else even[l]++;11});12const hashkey = even.join("") + odd.join("");13set.add(hashkey);14}15return set.size;16};