Skip to content

Commit 38853f9

Browse files
authored
Create Solution.java
1 parent e1b562c commit 38853f9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public int numEquivDominoPairs(int[][] dominoes) {
3+
Map<Integer, Integer> map = new HashMap<>();
4+
for (int[] d : dominoes) {
5+
int x = d[0] < d[1] ? d[0] * 10 + d[1] : d[1] * 10 + d[0];
6+
map.put(x, map.getOrDefault(x, 0) + 1);
7+
}
8+
int res = 0;
9+
for (int v : map.values()) {
10+
res += v * (v - 1) / 2;
11+
}
12+
return res;
13+
}
14+
}

0 commit comments

Comments
 (0)