java o(n) Solution
class Solution {\n    public int minDominoRotations(int[] tops, int[] bottoms) {\n        \n        int ans=Integer.MAX_VALUE;\n        for(int i=1;i<=6;i++)\n 
class Solution {\n    public int minDominoRotations(int[] tops, int[] bottoms) {\n        \n        int ans=Integer.MAX_VALUE;\n        for(int i=1;i<=6;i++)\n        {\n            int max=0;\n            for(int j=0;j<tops.length;j++)\n            {\n                if(tops[j]==i)\n                    continue;\n                else if(bottoms[j]==i)\n                    max++;\n                else\n                {\n                    max=-1;\n                    break;\n                }\n            }\n            if(max!=-1)\n                ans=Math.min(ans,max);\n        }\n        for(int i=1;i<=6;i++)\n        {\n            int max=0;\n            for(int j=0;j<tops.length;j++)\n            {\n                if(bottoms[j]==i)\n                    continue;\n                else if(tops[j]==i)\n                    max++;\n                else\n                {\n                    max=-1;\n                    break;\n                }\n            }\n            if(max!=-1)\n                ans=Math.min(ans,max);\n        }\n        return ans==Integer.MAX_VALUE?-1:ans;\n\n        \n    }\n}
['Greedy', 'Java']