Simple java solution
class Solution {\n\n    public int minDominoRotations(int[] t, int[] b) {\n        int k=t.length,s=Integer.MAX_VALUE;\n        for(int i=1;i<=6;i++)\n        {
class Solution {\n\n    public int minDominoRotations(int[] t, int[] b) {\n        int k=t.length,s=Integer.MAX_VALUE;\n        for(int i=1;i<=6;i++)\n        {\n            int j,p=0;\n            for(j=0;j<k;j++)\n            {\n                if(t[j]==i)\n                    continue;\n                else if(b[j]==i)\n                    p++;\n                else\n                    break;\n            }\n            if(j==k&&s>p)\n            {\n                s=p;\n            }\n        }\n        k=b.length;\n        for(int i=1;i<=6;i++)\n        {\n            int j,p=0;\n            for(j=0;j<k;j++)\n            {\n                if(b[j]==i)\n                    continue;\n                else if(t[j]==i)\n                    p++;\n                else\n                    break;\n            }\n            if(j==k&&s>p)\n            {\n                s=p;\n            }\n        }\n        return s == Integer.MAX_VALUE ? -1 : s;\n    }\n}
['Greedy', 'Java']