FastPrepSolve a Sudoku Board
Problems/Solve a Sudoku Board

Solve a Sudoku Board

ZipRecruiter logoZipRecruiter● HardFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A ZipRecruiter full-time onsite report explicitly names Sudoku Solver: fill a 9 by 9 board so every row, column, and 3 by 3 box is valid. The report leaves out a way to return the board, so our version returns the changed board for comparison.

Given a partially filled 9 x 9 Sudoku board, fill every empty cell so that the completed board is valid.

Each row, each column, and each of the nine 3 x 3 sub-boxes must contain the digits 1 through 9 exactly once. An empty cell contains '.'.

The given clues are valid, and the board has exactly one solution. Return the completed board.

Function

solveSudoku(board: char[][]) → char[][]

Examples

Example 1

board = [["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"]]return = [["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"]]
board
012345678053..7....16..195...2.98....6.38...6...344..8.3..157...2...66.6....28.7...419..58....8..79
→
return
012345678053467891216721953482198342567385976142344268537915713924856696153728472874196358345286179
Moved or new

The filled board contains every digit exactly once in each row, column, and sub-box.

Example 2

board = [[".","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","."]]return = [["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"]]
board
0123456780.346789121672195348219834256738597614234426853791571392485669615372847287419635834528617.
→
return
012345678053467891216721953482198342567385976142344268537915713924856696153728472874196358345286179
Moved or new

The two missing corner values are forced by their rows and columns.

Constraints

  • board.length == 9.
  • board[i].length == 9.
  • Every cell is '.' or a digit from '1' through '9'.
  • The given clues obey the Sudoku rules.
  • The board has exactly one solution.

More ZipRecruiter Onsite Interview questions

  • Restaurant Vote LeadersPHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2026
  • Sliding Window Rate LimiterOA · ONSITE INTERVIEW · Seen Oct 2022
  • Sort an Integer Array in Ascending OrderOA · ONSITE INTERVIEW · Seen Apr 2022
  • Classify an Alien Dictionary OrderingPHONE SCREEN · ONSITE INTERVIEW · Seen Mar 2022
  • Add Numbers Stored in Four-Digit ChunksONSITE INTERVIEW · Seen Nov 2021
  • Add Two Numeric Strings with CarryONSITE INTERVIEW · Seen Nov 2021
  • Expand Decimal Digits into Runs of OnesONSITE INTERVIEW · Seen Nov 2021
  • Validate a Sudoku BoardONSITE INTERVIEW · Seen Aug 2021
  • Iterate Ragged Integer Lists VerticallyONSITE INTERVIEW · Seen May 2017
  • Min StackONSITE INTERVIEW · Seen Feb 2017

Similar questions at other companies

  • Sudoku Puzzle SolverConfluent · PHONE SCREEN · ONSITE INTERVIEWConfluent interview questions
  • Sudoku SolverNutanix · ONSITE INTERVIEWNutanix interview questions
  • Sudoku SolverInMobi · PHONE SCREENInMobi interview questions
  • Sparse Plant Infection SimulationOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Word Search IIAmazon · ONSITE INTERVIEW
  • Rectangular K-in-a-RowDatabricks · ONSITE INTERVIEWDatabricks interview questions
  • Optimal Account BalancingPinterest · PHONE SCREEN · ONSITE INTERVIEWPinterest interview questions
  • Partition a Card Deck into FifteensMeta · ONSITE INTERVIEWMeta interview questions
  • Cache Shared Image Pipeline PrefixesAnthropic · ONSITE INTERVIEWAnthropic interview questions
  • Place K Buildings to Minimize Maximum Grid DistanceOracle · ONSITE INTERVIEWOracle interview questions

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public char[][] solveSudoku(char[][] board) {
        // write your code here
    }
}
Checking account…