Very Sure easy to understand || Faster than 90%||Minimum Domino Rotations For Equal Row
SIMPLE Brute Force method\nIn this we can !! use simple if else conditions !! to solve this question.\n\nclass Solution {\npublic:\n    int minDominoRotations(v
**SIMPLE Brute Force method**\nIn this we can !! **use simple if else conditions** !! to solve this question.\n```\nclass Solution {\npublic:\n    int minDominoRotations(vector<int>& tops, vector<int>& bottoms) \n    {\n        int n=tops.size(); //size of one of the vector\n        vector<int> nooftimes(7,0);//only 6 possible face number 1-6 (excluding 0)\n           for(int i=0;i<2*n;i++) //put in vector and increment for repeating element\n        {                         //nooftimes vector element shows the all occuring element from both input vector\n            if(i<n)  // i shows the element and nooftimes[i] indicate no of repeating \n            {\n                nooftimes[tops[i]]++;\n            }\n            else\n            {\n                nooftimes[bottoms[2*n-i-1]]++;\n            }\n        }\n        int maxi=0;\n        for(int i=1;i<7;i++) //calculating max from all occuring element \n        {\n            maxi=max(maxi,nooftimes[i]);//here the idea is max repeatation is the repeatation of desired element to be same in tops array or bottoms array.\n        }\n        int z=0;\n        for(int i=1;i<7;i++)  //  just storing the element which is the most occuring\n         {\n            if(nooftimes[i]==maxi)\n            {\n                z=i;\n            }\n         }\n        int count=0;\n        int count1=0;\n        int count2=0;\n        for(int i=0;i<tops.size();i++) // just count the most occuring element(z) in tops and bottom array and cal. separately\n        {\n            if(z==tops[i])\n            {\n                count1++;\n            }\n            if(z==bottoms[i])\n            {\n                count2++;\n            }\n        }\n        bool check=0; //if most occuring element is more in vector tops then it is min swap for \n\t\ttops vector to be same \n        if(count1>count2)\n        {\n            check=1; // this shows that check=1 that tops vector has more most occuring element  if check=0  bottoms vector has more most occuring element \n        }\n        if(maxi<tops.size())  //okay this is the intial checking that maxi should be greater than top.size() because if the maxi is less then not possible to one of vector elemnt to be same, if not understand lets take eg tops = [2,1,3,4,8,9], bottoms = [5,2,6,2,3,2] only 4times 2 is present not possible to put in vector in tops or bottoms \n        {\n            return -1;\n        }\n        else\n        {\n            for(int i=0;i<tops.size();i++)\n            {\n                if(tops[i]!=z && bottoms[i]!=z)   if pair not containing z that is most occuring element \n                {\n                    return -1;//not possible to swap\n                }\n                if(tops[i]==z && bottoms[i]==z)   // no need to swap\n                {\n                    continue;\n                }\n                if(check==1)// for tops vector to make same elements\n                {\n                  if(tops[i]!=z && bottoms[i]==z) //not swaping just count++ \n                   {\n                    count++;\n                   } \n                }\n                else\n                {\n                   if(tops[i]==z && bottoms[i]!=z)// for bottoms vector to make same elements\n                   {\n                    count++; // same not swaping just count++ \n                   } \n                }\n            }\n        }\n        return count; // final return count;\n    }\n};\n```\n//------------//---------//----------//-------------//-------------//----------//---------//-------------//----\n```\nif ( if you understand )\n     {\n          Upvote (this post);\n     }\nelse if (just want to know solution)\n     {\n    ignore(post);\n     }\nelse\n    {\n  UPVOTE\n   }\n   ```\n  !! Thanks !!
['C++']