# What is time complexity of this below code?

here below code is helping to solve sodoku , i understand the code but cannot find time complexity . please help me

``````import java.util.*;

class Solution {

public static boolean solveSudoku(char[][] board) {
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
if (board[i][j] == '.') {

for (char c = '1'; c <= '9'; c++) {
if (isValid(board, i, j, c)) {
board[i][j] = c;

if (solveSudoku(board))
return true;
else
board[i][j] = '.';
}
}

return false;
}
}
}
return true;
}

public static boolean isValid(char[][] board, int row, int col, char c) {
for (int i = 0; i < 9; i++) {
if (board[i][col] == c)
return false;

if (board[row][i] == c)
return false;

if (board[3 * (row / 3) + i / 3][3 * (col / 3) + i % 3] == c)
return false;
}
return true;
}

public static void main(String[] args) {

char[][] board= {
{'9', '5', '7', '.', '1', '3', '.', '8', '4'},
{'4', '8', '3', '.', '5', '7', '1', '.', '6'},
{'.', '1', '2', '.', '4', '9', '5', '3', '7'},
{'1', '7', '.', '3', '.', '4', '9', '.', '2'},
{'5', '.', '4', '9', '7', '.', '3', '6', '.'},
{'3', '.', '9', '5', '.', '8', '7', '.', '1'},
{'8', '4', '5', '7', '9', '.', '6', '1', '3'},
{'.', '9', '1', '.', '3', '6', '.', '7', '5'},
{'7', '.', '6', '1', '8', '5', '4', '.', '9'}
};
solveSudoku(board);

for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++)
System.out.print(board[i][j] + " ");
System.out.println();
}
}
}
``````

time complexity is given in dependence of variables that vary in size (your input). You don’t have any such variables, so giving this a time complexity is at least misleading, at worst wrong by definition.

If you don’t mind making potentially wrong statements, stating your solveSudoku()-method has time complexity O(1) is probably the closest to the truth.
wikipedia: “An algorithm is said to be constant time (also written as O(1)) if the value of T(n) (the complexity of the algorithm) is bounded by a value that does not depend on the size of the input”

but it is O(9^(nn) ) where nn is number of blank spaces