Sudoku Solver

Problem Id: 37 Difficulty: Hard Tag: Hash Table Tag: Backtracking


Intuition

This problem can be simply solved by DFS, while the code can be quite complex.

Solution


class Solution:
    def solveSudoku(self, board):
        """
        Do not return anything, modify board in-place instead.
        """
        self._dfsSolveSuduku(board)

    def _dfsSolveSuduku(self, board):
        for i in range(9):
            for j in range(9):
                if board[i][j] == '.':