Java use greedy
Not sure if it should be called greedy:\nkey point:\nIf it is doable, the total of a type should be more than N, considerring remove duplicated.\n\nif (cnta[i] 
Not sure if it should be called greedy:\nkey point:\nIf it is doable, the total of a type should be more than N, considerring remove duplicated.\n\nif (cnta[i] + cntb[i] - cnts[i] >= l) return Math.min(cnta[i], cntb[i]) - cnts[i];\n\n```\nclass Solution {\n    public int minDominoRotations(int[] A, int[] B) {\n        int l = A.length;\n        int k = B.length;\n        if (l != k) return -1;\n        if (l < 2) return 0;\n        int[] cnta = new int[7];\n        int[] cntb = new int[7];\n        int[] cnts = new int[7];\n        for (int i = 0; i < l; i++){\n            cnta[A[i]]++;\n            cntb[B[i]]++;\n            if (A[i] == B[i]) cnts[A[i]]++;\n        }\n        \n        for (int i = 1; i < 7; i++){\n            if (cnta[i] + cntb[i] - cnts[i] >= l) return Math.min(cnta[i], cntb[i]) - cnts[i];\n        }\n        return -1;\n    }\n}\n```\n
[]