Tap here to switch tabs
Problem
Submissions

Problem: Minimum Domino Rotations For Equal Row

med
30 min
Try to solve the Minimum Domino Rotations For Equal Row problem.

Statement

In a row of dominoes, each domino has two halves, represented by two integer arrays tops and bottoms, where tops[i] and bottoms[i] denote the top and bottom values of the ii-th domino tile respectively.

A rotation consists of swapping the top and bottom values of a domino tile at index i, swapping tops[i] and bottoms[i].

Return the minimum number of rotations required to make all the values in tops equal or all the values in bottoms equal. If it is impossible to make all values in either row equal, return −1-1.

Constraints:

  • 2≤2 \leq tops.length ≤2imes104\leq 2 imes 10^4

  • bottoms.length ==== tops.length

  • 1≤1 \leq tops[i], bottoms[i] ≤6\leq 6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Domino Rotations For Equal Row

med
30 min
Try to solve the Minimum Domino Rotations For Equal Row problem.

Statement

In a row of dominoes, each domino has two halves, represented by two integer arrays tops and bottoms, where tops[i] and bottoms[i] denote the top and bottom values of the ii-th domino tile respectively.

A rotation consists of swapping the top and bottom values of a domino tile at index i, swapping tops[i] and bottoms[i].

Return the minimum number of rotations required to make all the values in tops equal or all the values in bottoms equal. If it is impossible to make all values in either row equal, return −1-1.

Constraints:

  • 2≤2 \leq tops.length ≤2imes104\leq 2 imes 10^4

  • bottoms.length ==== tops.length

  • 1≤1 \leq tops[i], bottoms[i] ≤6\leq 6