Skip to content

Commit cb07aac

Browse files
authored
Create 893-groups-of-special-equivalent-strings.js
1 parent 203a2e2 commit cb07aac

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @param {string[]} A
3+
* @return {number}
4+
*/
5+
const numSpecialEquivGroups = function(A) {
6+
return new Set(
7+
A.map(word =>
8+
[...word]
9+
.reduce((counter, c, i) => {
10+
counter[c.charCodeAt(0) - "a".charCodeAt(0) + 26 * (i % 2)]++;
11+
return counter;
12+
}, new Array(52).fill(0))
13+
.join("-")
14+
)
15+
).size;
16+
};

0 commit comments

Comments
 (0)