Code RoomSudoku validity
MediumPrep Room Coding #421

Sudoku validity

CodingAlgorithms & data structuresMid–Senior~22 min

Given a 9x9 Sudoku board where '.' marks an empty cell, determine whether the currently filled cells are valid: no row, column, or 3x3 box contains a repeated digit '1'-'9'. You only validate the partial state; you do not solve it. Return True if valid, else False.

Implement
is_valid_sudoku(board: list[list[str]]) → bool
Examples
in[[["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"]]]outtrue
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 22 min
InputExpectedGot
[[["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"]]]truenot run yetsample