Number of Equivalent Domino Pairs LeetCode solution in JavaScript

1
var numEquivDominoPairs = function (dominoes) {
2
let map = {};
3
let count = 0;
4
for (let [a, b] of dominoes) {
5
if (b > a) {
6
[a, b] = [b, a];
7
}
8
let key = `${a}-${b}`;
9
if (map.hasOwnProperty(key)) {
10
map[key]++;
11
count += map[key];
12
} else {
13
map[key] = 0;
14
}
15
}
16
return count;
17
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0