🌻|| C++ || EASY APPROACH || PROPER EXPLANATION
APPROACH\n\n3 Things should be there in mind for solving this.\n-->what if for any ith position of both array doesnot contain the value that is needed to make a
APPROACH\n```\n3 Things should be there in mind for solving this.\n-->what if for any ith position of both array doesnot contain the value that is needed to make all faces same.\n-->what if top row doesnot have that value to make same.\n-->what if bottom row doesnot have that value to make same.\nIn first condition return -1 as at that position we can\'t make all the faces same in any circumstances.\nMaintain seprate count for 2nd and 3rd condition and written minimum among them.\nQuestion is that on what basis we are making all the faces same in any array same.\nAnswer->See we have to make all the faces same.\nSo i have only two possibile cases either make tops faces same or bottom faces same.\nSo i m checking for both the cases that for in which case i can get the same faces in min swaps.\nEx.\nINPUT\n\n          tops = [2,1,2,4,2,2]\n\t\t  bottoms = [5,2,6,2,3,2]\n\t\t  \nOUTPUT: 2\n Explanation : if i say i have to make all the faces same for tops. For this i need either 2 in all ith position of tops array or 5. Similarly for bottoms .\n So i know i need either 2 or 5 in my any one of the array.\n So check in which cases i can get same faces in min number of swaps.\n\t\t\n```\nCODE\n```\nclass Solution {\npublic:\n    \n    int countdiff(vector<int>&tops, vector<int>&bottoms, int num)\n    {\n        int top=0,bottom=0;\n        for(int i=0;i<tops.size();i++){\n            \n            if(tops[i]!=num && bottoms[i]!=num)     //if any value for num is not present at ith position of row and column than immediately return -1\n                return -1;\n            if(tops[i]!=num)\n                top++;\n            if(bottoms[i]!=num)\n                bottom++;\n        }\n        return min(top,bottom);\n    }\n    int minDominoRotations(vector<int>& tops, vector<int>& bottoms) {\n        \n        int swap1 = countdiff(tops,bottoms,tops[0]);\n        int swap2 = countdiff(tops,bottoms,bottoms[0]);\n        return(min(swap1,swap2)<0)?max(swap1,swap2):min(swap1,swap2);  //if swap is less than 0 then return max value to get positive value\n\n    }\n};\n```
['C']