C++ solution with hasmap | easy understanding with comments
\nclass Solution {\npublic:\n    int minDominoRotations(vector<int>& tops, vector<int>& bottoms) {\n        int ct = 0,cb = 0,cc = 0,i;\n        map<int,int> m;
```\nclass Solution {\npublic:\n    int minDominoRotations(vector<int>& tops, vector<int>& bottoms) {\n        int ct = 0,cb = 0,cc = 0,i;\n        map<int,int> m; // we create a map to store the count of each number appearing on the dice ( 1 to 6 )\n\t\t// by doing this we only serch for the number with max frequency as the req solution can be obtained from \n\t\t// max frequency number only \n\t\t\n\t\t// store freq\n        for(i=0;i<tops.size();i++){\n            m[tops[i]]++;\n            m[bottoms[i]]++;\n        }\n        int max=0,res=-1;\n        \n\t\t// find max freq in res variable\n        for(auto i:m){\n            if(max<i.second){\n                res = i.first;\n                max = i.second;\n            }\n        }\n        \n        for(i=0;i<tops.size();i++){\n            if(tops[i] == res && bottoms[i] == res){\n                cc++;                 // counter to count the common appearance of res in top and bottom vector\n            }\n            if(tops[i] == res){\n                ct++;               //counter to count the  appearance of res in top vector\n            }\n            if(bottoms[i] == res){\n                cb++;                  //counter to count the  appearance of res in bottom vector\n            }\n        }\n              \n        if(ct+cb-cc != tops.size()) return -1; // now if the total of both vectors - the common count doesnt come out \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// to be the size of original vec then there is no solution and return -1\n        \n        res = min(cb,ct) - cc;                     // now find the min of both counts and substract it from common count to \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// get the number of min no. of flips\n        return res;\n        \n      \n    }\n};\n```
['C']