From 985d9d52b0438b906b618da460e1caf326136fda Mon Sep 17 00:00:00 2001 From: chayan das Date: Sat, 3 May 2025 14:02:17 +0530 Subject: [PATCH] Create 1007. Minimum Domino Rotations For Equal Row --- 1007. Minimum Domino Rotations For Equal Row | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 1007. Minimum Domino Rotations For Equal Row 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; + } +};