# Java solution with List and Set

• public class Solution {
List<Set<Character>> row = new ArrayList<Set<Character>>();
List<Set<Character>> col = new ArrayList<Set<Character>>();
List<Integer[]> blank = new ArrayList<Integer[]>();
Set<Character>[][] sub = new HashSet[3][3];

``````public boolean backCheck(int ind, char[][] board) {
if(ind == blank.size()) return true;

Integer[] target = blank.get(ind);
boolean finished = false;

for(char i='1'; i<='9'; i++)
if(!row.get(target[0]).contains(i) && !col.get(target[1]).contains(i) && !sub[target[0]/3][target[1]/3].contains(i)) {
board[target[0]][target[1]] = i;
if(backCheck(ind+1, board)) {
finished = true;
break;
}
row.get(target[0]).remove(i);
col.get(target[1]).remove(i);
sub[target[0]/3][target[1]/3].remove(i);
}

return finished?true:false;
}

public void solveSudoku(char[][] board) {
if(board == null) return;

for(int i=0; i<board.length; i++) {
Set<Character> r = new HashSet<Character>();
Set<Character> c = new HashSet<Character>();
}
for(int i=0; i<board.length/3; i++)
for(int j=0; j<board.length/3; j++) {
Set<Character> s = new HashSet<Character>();
sub[i][j] = s;
}

for(int i=0; i<board.length; i++)
for(int j=0; j<board[i].length; j++)
if(board[i][j] != '.') {
} else {
Integer[] b = new Integer[2];
b[0] = i;
b[1] = j;