Implement the validSudokuRowsSimple method that checks whether each row of a Sudoku board is valid.
The input contains a character matrix board and its size n. Your task is to check whether each row is valid.
For this simplified Sudoku-style problem, a row is valid when it does not contain the same non-empty value more than once in that row.
For example, the row [1,2,3] is valid, but [1,1,3] is invalid because 1 appears twice in the same row.
Check each row separately using a set.
For every row, clear the set before scanning its cells. If a value already exists in the set, that row contains a duplicate and the board fails the row validation.
If all rows are scanned without finding a duplicate, return true.
Pseudocode:
function validSudokuRowsSimple(board, n):
for r from 0 to n - 1:
create empty set seen
for c from 0 to n - 1:
value = board[r][c]
if value exists in seen:
return false
add value to seen
return true