Be the first user to complete this post
|Add to List|
Check if given sudoku is valid or not
Problem: Given a filled sudoku, write a program to check if sudoku is valid or following all of its rules.
- Each column contains all of the digits from 1 to 9 only once.
- Each row contains all of the digits from 1 to 9 only once.
- Each of the nine 3×3 sub-grid contains all of the digits from 1 to 9 only once.
If we go by the rules of sudoku, we need a function for each rule (row, column and 3x3 matrix). Each function will validate whether all numbers from 1 to 9 are present and there are no duplicates present. There are 9 rows, 9 columns and 9 3x3 matrix, we will validate each of those.
See the code below for more understanding.
Given SUDOKU is valid
- Find All Elements in an Array which appears more than N/K times, N is Array Size and k is a Number. Hard