package leetcode;

/**
 * https://leetcode.com/problems/score-after-flipping-matrix/
 */
public class Problem861 {
    public int matrixScore(int[][] A) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem861 prob = new Problem861();
//            {1, 1, 1, 1},
//            {1, 0, 0, 1},
//            {1, 1, 1, 1}
        System.out.println(prob.matrixScore(new int[][]{
            {0, 0, 1, 1},
            {1, 0, 1, 0},
            {1, 1, 0, 0}
        })); // 39
    }
}

@@ -160,32 +160,1420 @@
     
-// TODO%0A        return 0
+int nRow = A.length;%0A        int nCol = A.length %3E 0 ? A%5B0%5D.length : 0;%0A        int%5B%5D score = score(A);%0A        for (int col = 0; col %3C nCol; col++) %7B%0A            String s = %22%22;%0A            int%5B%5D newCol = new int%5BnRow%5D;%0A            for (int row = 0; row %3C nRow; row++) %7B%0A                if (A%5Brow%5D%5Bcol%5D == 0) %7B%0A%0A                %7D else %7B%0A%0A                %7D%0A            %7D%0A        %7D%0A        for (int row = 0; row %3C nRow; row++) %7B%0A            String s = %22%22;%0A            int%5B%5D newRow = new int%5BnCol%5D;%0A            for (int col = 0; col %3C nCol; col++) %7B%0A                if (A%5Brow%5D%5Bcol%5D == 0) %7B%0A                    s += %221%22;%0A                    newRow%5Bcol%5D = 1;%0A                %7D else %7B%0A                    s += %220%22;%0A                    newRow%5Bcol%5D = 0;%0A                %7D%0A            %7D%0A            int val = Integer.parseInt(s, 2);%0A            if (val %3E score%5Brow%5D) %7B%0A                score%5Brow%5D = val;%0A                A%5Brow%5D = newRow;%0A            %7D%0A        %7D%0A        int totalScore = 0;%0A        for (int s : score) %7B%0A            totalScore += s;%0A        %7D%0A        return totalScore;%0A    %7D%0A%0A    private static int%5B%5D score(int%5B%5D%5B%5D a) %7B%0A        int%5B%5D score = new int%5Ba.length%5D;%0A        for (int i = 0; i %3C a.length; i++) %7B%0A            String s = %22%22;%0A            for (int j = 0; j %3C a%5Bi%5D.length; j++) %7B%0A                s += a%5Bi%5D%5Bj%5D;%0A            %7D%0A            score%5Bi%5D = Integer.parseInt(s, 2);%0A        %7D%0A        return score
 ;%0A  

Update problem 861