package leetcode;

import java.util.Arrays;

/**
 * https://leetcode.com/problems/sudoku-solver/
 */
public class Problem37 {
    public void solveSudoku(char[][] board) {
        // TODO
    }

    private static void print(char[][] board) {
        for (char[] c : board) {
            System.out.println(Arrays.toString(c));
        }
    }

    public static void main(String[] args) {
        Problem37 prob = new Problem37();
        prob.solveSudoku(new char[][]{
            {'5', '3', '.', '.', '7', '.', '.', '.', '.'},
            {'6', '.', '.', '1', '9', '5', '.', '.', '.'},
            {'.', '9', '8', '.', '.', '.', '.', '6', '.'},
            {'8', '.', '.', '.', '6', '.', '.', '.', '3'},
            {'4', '.', '.', '8', '.', '3', '.', '.', '1'},
            {'7', '.', '.', '.', '2', '.', '.', '.', '6'},
            {'.', '6', '.', '.', '.', '.', '2', '8', '.'},
            {'.', '.', '.', '4', '1', '9', '.', '.', '5'},
            {'.', '.', '.', '.', '8', '.', '.', '7', '9'},
        });
    }
}

@@ -184,24 +184,1620 @@
 TODO%0A    %7D%0A%0A
+    private static boolean isValid(char%5B%5D%5B%5D board) %7B%0A        for (int i = 0; i %3C 9; i++) %7B%0A            boolean%5B%5D cols = new boolean%5B9%5D;%0A            boolean%5B%5D rows = new boolean%5B9%5D;%0A            for (int j = 0; j %3C 9; j++) %7B%0A                if (board%5Bi%5D%5Bj%5D != '.') %7B%0A                    if (cols%5Bboard%5Bi%5D%5Bj%5D - '0' - 1%5D) %7B%0A                        return false;%0A                    %7D%0A                    cols%5Bboard%5Bi%5D%5Bj%5D - '0' - 1%5D = true;%0A                %7D%0A%0A                if (board%5Bj%5D%5Bi%5D != '.') %7B%0A                    if (rows%5Bboard%5Bj%5D%5Bi%5D - '0' - 1%5D) %7B%0A                        return false;%0A                    %7D%0A                    rows%5Bboard%5Bj%5D%5Bi%5D - '0' - 1%5D = true;%0A                %7D%0A            %7D%0A        %7D%0A        for (int i = 0; i %3C 9; i += 3) %7B%0A            for (int j = 0; j %3C 9; j += 3) %7B%0A                if (!isValid(board, i, i + 3, j, j + 3)) %7B%0A                    return false;%0A                %7D%0A            %7D%0A        %7D%0A        return true;%0A    %7D%0A%0A    private static boolean isValid(char%5B%5D%5B%5D board, int startRow, int endRow,%0A                                   int startCol, int endCol) %7B%0A        boolean%5B%5D b = new boolean%5B9%5D;%0A        for (int i = startRow; i %3C endRow; i++) %7B%0A            for (int j = startCol; j %3C endCol; j++) %7B%0A                if (board%5Bi%5D%5Bj%5D == '.') %7B%0A                    continue;%0A                %7D%0A                if (b%5Bboard%5Bi%5D%5Bj%5D - '0' - 1%5D) %7B%0A                    return false;%0A                %7D%0A                if (board%5Bi%5D%5Bj%5D != '.') %7B%0A                    b%5Bboard%5Bi%5D%5Bj%5D - '0' - 1%5D = true;%0A                %7D%0A            %7D%0A        %7D%0A        return true;%0A    %7D%0A%0A
     private 

Update problem 37