title: What's time complexity of this algorithm for solving Sudoku?
body: <blockquote>
    <p><strong>Sudoku Solver</strong><br> Write a program to solve a Sudoku puzzle by filling the empty cells.<br></p>
    
    <p>Empty cells are indicated by the character '.'.<br> You may assume
    that there will be only <strong>one unique solution</strong>.<br> <hr>
    <strong>Personally I think,</strong><br> time complexity = O((n^2)!), n is the number of rows(cols) of the board.<br> <hr>
    <strong>C++</strong></p>
  </blockquote>
  
  <pre><code>class Solution {
  public:
      void solveSudoku(vector&lt;vector&lt;char&gt; &gt; &amp;board) {
          // Input validation.
          if (board.size() == 0 ||
              board.size() != board[0].size() ||
              board.size() % 3 != 0) return;
  
          helper(board);
      }
  
      bool helper(vector&lt;vector&lt;char&gt;&gt;&amp; board) {
          // Base case.
          // ... ...
  
          for (int row = 0; row &lt; board.size(); row ++) {
              for (int col = 0; col &lt; board[0].size(); col ++) {
                  if (board[row][col] != '.') continue;
  
                  for (char num = '1'; num &lt;= '9'; num ++) {
                      if (isValid(board, num, row, col)) {
                          // Have a try.
                          board[row][col] = num;
  
                          // Do recursion.
                          if (helper(board)) return true;;
  
                          // Roll back.
                          board[row][col] = '.';
                      }
                  }
                  // Can not find a suitable number[1-9].
                  return false;
              }
          }
  
          return true;
      }
  
      bool isValid(const vector&lt;vector&lt;char&gt;&gt;&amp; board, char num, int row, int col) {
          // Check row.
          for (int tmp_col = 0; tmp_col &lt; board[0].size(); tmp_col ++) {
              if (board[row][tmp_col] == num) return false;
          }
  
          // Check col.
          for (int tmp_row = 0; tmp_row &lt; board.size(); tmp_row ++) {
              if (board[tmp_row][col] == num) return false;
          }
  
          // Check sub square.
          int start_row = (row / 3) * 3;
          int start_col = (col / 3) * 3;
          for (int row = start_row; row &lt; start_row + 3; row ++) {
              for (int col = start_col; col &lt; start_col + 3; col ++) {
                  if (board[row][col] == num) return false;
              }
          }
  
          return true;
      }
  };
  </code></pre>