Valid Sudoku

Moderate
0/80
0 upvote
Asked in company
Cimba.ai

Problem statement

You are given a (9X9) square integer matrix, that contains values between 0-9.This matrix represents a sudoku. Check if sudoku is valid or not.

- The sudoku can be completely filled or partially filled.
- An entry 0 indicates that the corresponding cell is empty.
- Your task is to find out whether this sudoku is valid or not.
- Standard sudoku rules are to be enforced to check whether a sudoku is valid/invalid.
    1. No value should be repeating in a given row.
    2. No value should be repeating in a given column.
    3. No value should be repeating in each of the 9 (3X3) square grids.
- Return a boolean response.
Detailed explanation ( Input/output format, Notes, Images )
Input Format :
 Line 1 : contains the corresponding ith and jth entries of the 2D matrix
Sample Output :
true or false
Sample Input :
6   0   8   2   5   1   7   3   0  
2   3   7   6   9   4   5   1   0  
1   5   9   3   8   7   6   4   0
3   7   1   9   6   0   4   8   5
5   9   0   1   4   8   3   6   7  
8   6   4   7   0   5   9   2   0
7   8   5   4   0   3   1   0   6
4   2   6   5   1   9   8   7   3
9   1   3   8   7   6   2   5   4 
Sample Output :
true
Approaches (1)
Time Complexity
Space Complexity
Code Solution
(100% EXP penalty)
Valid Sudoku
Full screen
Console