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:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Check if given Sudoku solution is valid or not
- Validity of a given Tic-Tac-Toe board configuration
- Check if the given chessboard is valid or not
- Check if a king can move a valid move or not when N nights are there in a modified chessboard
- Program for Sudoku Generator
- Sudoku | Backtracking-7
- 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 if a given matrix is sparse or not
- Check given matrix is magic square or not
- Check if a given matrix is Hankel or not
- Check if it is possible to make the given matrix increasing matrix or not
- Check if a cycle of length 3 exists or not in a graph that satisfy a given condition
- Check whether the given Matrix is balanced or not
- Check if the Matrix follows the given constraints or not
- Check whether a given matrix is orthogonal or not
- Quickly check if two STL vectors contain same elements or not
- Program to check if matrix is singular or not
- Program to check if a matrix is Binary matrix or not
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