Given a Sudoku Board configuration, check whether it is valid or not.
Input: [5 3 - - 7 - - - -] [6 - - 1 9 5 - - -] [- 9 8 - - - - 6 -] [8 - - - 6 - - - 3] [4 - - 8 - 3 - - 1] [7 - - - 2 - - - 6] [- 6 - - - - 2 8 -] [- - - 4 1 9 - - 5] [- - - - 8 - - 7 9] Output: True
The basic idea is to check whether each row, column, and the 3×3 box is valid or not on the basis of following points:
- The Sudoku board could be partially filled, where empty cells are filled with the character ‘.’.
- An empty Sudoku board is also valid.
- A valid Sudoku board (partially filled) is not necessarily solvable. Only the filled cells need to be validated.
Below is the implementation of above approach:
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Validity of a given Tic-Tac-Toe board configuration
- Check if the given chessboard is valid or not
- Sudoku | Backtracking-7
- Program for Sudoku Generator
- Check if a king can move a valid move or not when N nights are there in a modified chessboard
- Minimum queens required to cover all the squares of a chess board
- Expected number of moves to reach the end of a board | Dynamic programming
- Expected number of moves to reach the end of a board | Matrix Exponentiation
- Check for possible path in 2D matrix
- Check whether Bishop can take down Pawn or not
- Check if a given matrix is Hankel or not
- Check whether a given matrix is orthogonal or not
- Check mirror in n-ary tree
- Check if it is possible to get given sum by taking one element from each row
- Check if two trees are Mirror
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : rituraj_jain