Tap here to switch tabs
Problem
Submissions

Problem: Number of Equivalent Domino Pairs

med
30 min
Try to solve the Number of Equivalent Domino Pairs problem.

Statement

Given an array dominoes where each domino is represented as a pair of integers dominoes[i] = [a, b].

Two dominoes dominoes[i] = [a, b] and dominoes[j] = [c, d] are considered equivalent if and only if either (a == c and b == d) or (a == d and b == c), meaning one domino can be rotated to match the other.

Return the total number of pairs (i,j)(i, j) such that 0≤i<j<0 \leq i < j < dominoes.length, where dominoes[i] is equivalent to dominoes[j].

Constraints:

  • 1≤1 \leq dominoes.length ≤4imes104\leq 4 imes 10^4

  • dominoes[i].length =2= 2

  • 1≤1 \leq dominoes[i][j] ≤9\leq 9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Equivalent Domino Pairs

med
30 min
Try to solve the Number of Equivalent Domino Pairs problem.

Statement

Given an array dominoes where each domino is represented as a pair of integers dominoes[i] = [a, b].

Two dominoes dominoes[i] = [a, b] and dominoes[j] = [c, d] are considered equivalent if and only if either (a == c and b == d) or (a == d and b == c), meaning one domino can be rotated to match the other.

Return the total number of pairs (i,j)(i, j) such that 0≤i<j<0 \leq i < j < dominoes.length, where dominoes[i] is equivalent to dominoes[j].

Constraints:

  • 1≤1 \leq dominoes.length ≤4imes104\leq 4 imes 10^4

  • dominoes[i].length =2= 2

  • 1≤1 \leq dominoes[i][j] ≤9\leq 9