Validate Completed Sudoku
Reported by candidates from Apple's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The Apple OA reported in July 2026 hands you a finished 9 x 9 Sudoku board and asks if it's valid. It looks like a warm-up, and that's the trap. A solution that only checks for duplicates can pass the sample and still fail on a board with a bad value in it. It's a hash-table and set problem at heart: three passes of the same check, rows, columns, and boxes. If you blank on the box indexing, StealthCoder runs invisibly during the live assessment as a safety net. Know the shape first and you probably won't need it.
The problem
You are given a completed 9 x 9 Sudoku board. Return true if the board is valid, meaning every row, every column, and every 3 x 3 sub-grid contains no duplicate digits and follows Sudoku rules. Otherwise return false. Function isCompletedSudokuValid(board: String[][]) → boolean Examples Example 1 board = [["5","3","4","6","7","8","9","1","2"],["6","7","2","1","9","5","3","4","8"],["1","9","8","3","4","2","5","6","7"],["8","5","9","7","6","1","4","2","3"],["4","2","6","8","5","3","7","9","1"],["7","1","3","9","2","4","8","5","6"],["9","6","1","5","3","7","2","8","4"],["2","8","7","4","1","9","6","3","5"],["3","4","5","2","8","6","1","7","9"]] return = true Every row, column, and 3 x 3 sub-grid contains each digit exactly once. The source shared the rule but did not include this exact sample. FastPrep added this small example so the behavior can be checked directly.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is that the board is completed, so every row, column, and 3 x 3 box must contain exactly the digits 1 through 9. Checking for duplicates alone is the naive approach and it misses cells holding something outside 1-9, like "0" or ".". Validate each cell value, then track seen digits in sets. Use one pass over 81 cells with 9 row sets, 9 column sets, and 9 box sets. The box index is (r // 3) * 3 + (c // 3). Most bugs live there, usually in swapped row and column terms. Another pitfall is comparing strings to ints inconsistently. The board is String[][], so keep digits as strings or convert once. Time is O(81), effectively constant. If the box math slips under pressure, StealthCoder is the hedge for the live OA: it reads the prompt and gives you a working version while you stay calm.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Validate Completed Sudoku cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as valid sudoku. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Apple's OA.
Apple reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Validate Completed Sudoku FAQ
How hard is the Apple validate completed Sudoku question really?+
Easy to medium. The algorithm is simple, but the bugs hide in box indexing and input validation. If you've written the 3 x 3 box formula once, you can finish it quickly. Most failures come from rushing the edge cases, not from missing a concept.
What's the trick to this problem?+
Use sets for rows, columns, and boxes, and compute the box with (r // 3) * 3 + (c // 3). Since the board is completed, also confirm each cell is a digit from 1 to 9. Return false the moment you see a repeat or an invalid value.
What edge case breaks a naive solution?+
A naive duplicate check ignores cells that aren't valid digits, such as 0 or a dot. On a completed board those must fail. Also watch for string versus integer comparison, where "5" and 5 never match in a set and hide a duplicate.
Do I need to check each unit separately or can I do it in one pass?+
One pass works. Loop all 81 cells, and for each digit check the row set, column set, and box set. If it's already in any of them, return false. Otherwise add it to all three. It's clean, fast, and easy to debug.
How do I prepare for this in 48 hours?+
Write the one-pass set solution from scratch twice, without looking. Then test it with a duplicate in a row, a duplicate in a column, a duplicate only inside a box, and a cell holding 0. If those four cases pass, you're ready for the assessment.