We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e1b562c commit 38853f9Copy full SHA for 38853f9
solution/1128.Number of Equivalent Domino Pairs/Solution.java
@@ -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