diff --git a/1007. Minimum Domino Rotations For Equal Row b/1007. Minimum Domino Rotations For Equal Row new file mode 100644 index 0000000..b88844b --- /dev/null +++ b/1007. Minimum Domino Rotations For Equal Row @@ -0,0 +1,17 @@ +class Solution { +public: + int minDominoRotations(vector& tops, vector& bottoms) { + int n = tops.size(); + vector top(7, 0), btm(7, 0), same(7, 0); + for (int i = 0; i < n; i++) { + top[tops[i]]++; + btm[bottoms[i]]++; + if (tops[i] == bottoms[i]) + same[tops[i]]++; + } + for (int num = 1; num <= 6; num++) + if (top[num] + btm[num] - same[num] == n) + return min(n - top[num], n - btm[num]); + return -1; + } +};