FastPrepSudoku Solver
Problems/Sudoku Solver

Sudoku Solver

InMobi logoInMobi● HardFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an InMobi phone screen. The interview report names and links the well-known Sudoku Solver task. It does not give the statement or limits. Our version is about 98% the same as the linked task.

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. Empty cells are represented by '.'.

The input is guaranteed to have 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

Filling the empty cells produces a board whose rows, columns, and sub-boxes each contain every digit exactly once.

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 missing top-left and bottom-right digits are forced by their rows and columns.

Constraints

  • board.length == 9
  • board[i].length == 9
  • Every cell is '.' or a digit from '1' to '9'.
  • The given digits do not violate Sudoku rules.
  • The board has exactly one solution.

More InMobi Phone Screen questions

  • House Robber IPHONE SCREEN · Seen Aug 2026
  • Word Break IIPHONE SCREEN · Seen Aug 2026
  • Bus Station Seat AllotmentPHONE SCREEN · Seen Mar 2026
  • Find Missing and Duplicate IntegerPHONE SCREEN · Seen Mar 2026
  • Frequency Equals Card ValuePHONE SCREEN · Seen Mar 2026
  • Frog Position After T SecondsPHONE SCREEN · Seen Mar 2026
  • IPOPHONE SCREEN · Seen Mar 2026
  • Evaluate DivisionPHONE SCREEN · Seen Dec 2025
  • Compare Version NumbersPHONE SCREEN · Seen Feb 2022
  • Count Array DerangementsPHONE SCREEN · Seen Feb 2022

Similar questions at other companies

  • Sudoku Puzzle SolverConfluent · PHONE SCREEN · ONSITE INTERVIEWConfluent interview questions
  • Solve a Sudoku BoardZipRecruiter · ONSITE INTERVIEWZipRecruiter interview questions
  • Sudoku SolverNutanix · ONSITE INTERVIEWNutanix interview questions
  • Sparse Plant Infection SimulationOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Choose the Next Minesweeper ActionRunloop · PHONE SCREEN
  • Optimal Account BalancingPinterest · PHONE SCREEN · ONSITE INTERVIEWPinterest interview questions
  • Word Break IIAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Word Break IIWex · PHONE SCREEN
  • Optimal Account BalancingSalesforce · PHONE SCREENSalesforce interview questions
  • Word Break IIBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
All InMobi interview questionsSee InMobi hiring insights
Saved
class Solution {
    public char[][] solveSudoku(char[][] board) {
        // write your code here
    }
}
Checking account…