Skip to content

Commit 4d897bf

Browse files
committed
May 04
1 parent 1313c74 commit 4d897bf

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from collections import defaultdict
2+
3+
4+
class Solution:
5+
def numEquivDominoPairs(self, dominoes: list[list[int]]) -> int:
6+
counts = defaultdict(int)
7+
pairs = 0
8+
for domino in map(tuple, (map(sorted, dominoes))):
9+
pairs += counts[domino]
10+
counts[domino] += 1
11+
return pairs
12+
13+
14+
def main():
15+
dominoes = [[1, 2], [2, 1], [3, 4], [5, 6]]
16+
assert Solution().numEquivDominoPairs(dominoes) == 1
17+
18+
dominoes = [[1, 2], [1, 2], [1, 1], [1, 2], [2, 2]]
19+
assert Solution().numEquivDominoPairs(dominoes) == 3
20+
21+
22+
if __name__ == '__main__':
23+
main()

2025-05-May-LeetCoding-Challenge/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
| May 01 | [2071. Maximum Number of Tasks You Can Assign](https://leetcode.com/problems/maximum-number-of-tasks-you-can-assign/) | Hard | Solved |
88
| May 02 | [838. Push Dominoes](https://leetcode.com/problems/push-dominoes/) | Medium | Solved |
99
| May 03 | [1007. Minimum Domino Rotations For Equal Row](https://leetcode.com/problems/minimum-domino-rotations-for-equal-row/) | Medium | Solved |
10-
| May 04 | []() | | |
10+
| May 04 | [1128. Number of Equivalent Domino Pairs](https://leetcode.com/problems/number-of-equivalent-domino-pairs/) | Easy | Solved |
1111
| May 05 | []() | | |
1212
| May 06 | []() | | |
1313
| May 07 | []() | | |
@@ -40,6 +40,6 @@
4040
## Summary
4141
| Level | Problems | Solved | Unsolved |
4242
| --- | --- | --- | --- |
43-
| Easy | 0 | 0 | 0 |
43+
| Easy | 1 | 1 | 0 |
4444
| Medium | 2 | 2 | 0 |
4545
| Hard | 1 | 1 | 0 |

0 commit comments

Comments
 (0)