The Number of Equivalent Domino Pairs problem gives you a list of dominoes, where each domino is a pair [a, b]. Two dominoes [a,b] and [c,d] are equivalent if (a==c && b==d) or (a==d && b==c). Count the number of equivalent pairs. This Number of Equivalent Domino Pairs coding problem uses normalization and hash map counting.
Amazon, Google, and Bloomberg ask this easy problem to test pair normalization and combination counting. By normalizing each domino (smaller value first), equivalent dominoes map to the same key. For a group of size m, the pairs count = m*(m-1)/2. The array, hash table, and counting interview pattern is demonstrated.
Normalize + frequency count + combination formula. For each domino [a,b], normalize to (min(a,b), max(a,b)). Build a frequency map. For each frequency m, add m*(m-1)/2 to the result (number of pairs from the group).
Dominoes: [[1,2],[2,1],[3,4],[5,6],[1,2]]. Normalized: (1,2),(1,2),(3,4),(5,6),(1,2). Frequencies: {(1,2):3, (3,4):1, (5,6):1}. Pairs from (1,2): C(3,2)=3. Others: 0. Total = 3.
Pair equivalence problems always require normalization first. The pattern: normalize → count frequencies → sum C(freq,2) for each group. This avoids O(n²) pair checking entirely. The combination formula C(m,2) = m*(m-1)/2 is used whenever you need to count unordered pairs within a frequency group. Practice "count equivalent pairs" problems with different normalization schemes (sort, min/max, canonical form) to build this recognition quickly.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Most Frequent Even Element | Easy | Solve | |
| Find Lucky Integer in an Array | Easy | Solve | |
| Sum of Unique Elements | Easy | Solve | |
| Count Elements With Maximum Frequency | Easy | Solve | |
| Most Frequent Number Following Key In an Array | Easy | Solve |