C++ || O(n) || No Extra Space (optimized)
\nclass Solution {\npublic:\n    int minDominoRotations(vector<int>& tops, vector<int>& bottoms) {\n        int n=tops.size(),k=1,c1=0,c2=0;\n        for(int i=
```\nclass Solution {\npublic:\n    int minDominoRotations(vector<int>& tops, vector<int>& bottoms) {\n        int n=tops.size(),k=1,c1=0,c2=0;\n        for(int i=0;i<n && k<7;i++)\n        {\n            if(tops[i]!=k && bottoms[i]!=k )\n            {\n                k++;\n                i=-1;\n                c1=0;\n                c2=0;\n            }\n            else if(tops[i]!=k) c1++;\n            else if(bottoms[i]!=k) c2++;\n            if(i==n-1)\n                return min(c1,c2);\n        }\n        return -1;\n    }\n};\n```
[]