Customized Chess Board

  • + 0 comments

    static String solve(List> board) {

        for (int i = 0; i < board.size()-1; i++) {
            List<Integer> row = board.get(i);
            List<Integer> col1 = board.get(i+1);
            int col=0;
            for (int k = 1; k < row.size(); k++) {
                int val = row.get(k);
                if(val==row.get(col)) {
                    return "No";
                }
                else {
                    col++;
                }
            }
    
            for (int k = 0; k < row.size(); k++) {
                int val1=col1.get(k);
                int val = row.get(k);
                if(val==val1) {
                    return "No";
                }
            }
    
    
        }
        return "Yes";
    }