Skip to content

1007. Minimum Domino Rotations For Equal Row #1638

Answered by mah-shamim
mah-shamim asked this question in Q&A
Discussion options

You must be logged in to vote

We need to determine the minimum number of rotations required to make all values in either the top row or the bottom row of a set of dominoes the same. If it is not possible, we should return -1.

Approach

  1. Identify Candidates: The target value (which all dominoes must be rotated to) must be present in either the top or bottom of the first domino. This is because if the target value is not in the first domino, it is impossible to make all values in either row match that target.
  2. Check Validity: For each candidate value from the first domino, check if every domino can contribute this value to either the top or bottom row. If any domino cannot contribute this value, the candidate is invalid.
  3. C…

Replies: 1 comment 2 replies

Comment options

mah-shamim
May 3, 2025
Maintainer Author

You must be logged in to vote
2 replies
@basharul-siddike
Comment options

@mah-shamim
Comment options

mah-shamim May 3, 2025
Maintainer Author

Answer selected by basharul-siddike
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested medium Difficulty
2 participants