A row of dominoes is described by `tops[i]` and `bottoms[i]`, the top and bottom halves of the `i`th domino (each a number from 1 to 6). One rotation swaps the two halves of a single domino. Return the minimum number of rotations that makes every value in `tops` equal, or every value in `bottoms` equal. If neither is possible, return `-1`.
A row of dominoes is described by tops[i] and bottoms[i], the top and bottom halves of the ith domino (each a number from 1 to 6). One rotation swaps the two halves of a single domino. Return the minimum number of rotations that makes every value in tops equal, or every value in bottoms equal. If neither is possible, return -1.