Sudoku Valid Rows and Columns

JavaScript Hard 3 views
Back to Questions

Problem Description

Given 9x9 grid (0 means empty), check if rows and columns are valid (no duplicate 1..9). Print YES or NO.

Input Format

9 lines, each has 9 integers.

Output Format

YES or NO.

Sample Test Case

Input:
5 3 0 0 7 0 0 0 0 6 0 0 1 9 5 0 0 0 0 9 8 0 0 0 0 6 0 8 0 0 0 6 0 0 0 3 4 0 0 8 0 3 0 0 1 7 0 0 0 2 0 0 0 6 0 6 0 0 0 0 2 8 0 0 0 0 4 1 9 0 0 5 0 0 0 0 8 0 0 7 9
Output:
YES

Constraints

All values are 0..9.

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next