Valid Sudoku
Problem Statement
You are given a 9×9 Sudoku board that is only partly filled. Empty cells hold '.'.
Decide if the board is valid so far. Only look at the filled cells. The board is valid when:
- no digit appears twice in the same row,
- no digit appears twice in the same column,
- no digit appears twice in the same 3×3 box (the nine boxes that split the grid).
You do not need to check whether the puzzle can actually be solved.
board: a 9×9 grid of characters, each '1'–'9' or '.'.
true if no row, column or 3×3 box contains a repeated digit, otherwise false.
Every row, column and 3×3 box has each digit at most once.
Now column 0 has two 8s (rows 0 and 3), and the top-left box also has two 8s (at (0,0) and (2,2)). One repeat is enough to make it invalid.
- • board.length == 9
- • board[i].length == 9
- • board[i][j] is a digit '1'–'9' or '.'
Pattern Recognition Clues
Recognising these key signals in the problem description immediately identifies the pattern:
Approach Complexity Ladder
For each filled cell, look through its row, column and box for the same digit
Keep a seen-set for every row, column and box; one pass over the board
Take each filled cell one by one. Walk along its row, down its column and through its 3×3 box, and see if any other cell has the same digit. If any does, the board is invalid.
Recognition rule for this sub-pattern:
Unlock Complete Visual Walkthrough & Optimal C++
The interactive animated dry-run player, optimized C++ implementation, state invariant derivations, and edge-case breakdown for this question are part of Brute2Best Pro. The anchor question of every sub-pattern is completely free.
First anchor question per pattern, Part 1 LLD & Module 1 C++ basics are 100% Free forever.
How this concept connects to System Design & C++ Systems
Top engineering interviews test whether you understand how algorithms like Arrays & Hashing translate into production architectures and low-level memory mechanics.