FastPrepComplete a Sudoku Board
Problems/Complete a Sudoku Board

Complete a Sudoku Board

JP Morgan Chase logoJP Morgan Chase● HardINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a JP Morgan Chase intern online assessment. Both internship reports ask to solve Sudoku. One uses zeros for blank cells and asks to print the solved grid. This exercise is about 95% the same as that completion task. We chose the returned matrix, the guarantee of a valid input with a unique solution, and every test grid. The original assessment grids were not recovered.

Complete the 9 x 9 Sudoku board. A zero marks an unfilled cell; replace every zero with a digit from 1 through 9. Keep every original nonzero value unchanged.

The completed board must contain each digit from 1 through 9 exactly once in every row, every column and each of the nine aligned 3 x 3 boxes.

Return the completed matrix. Zeros mark blanks in the input. Each board has a unique solution.

Function

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

Examples

Example 1

board = [[5,3,0,0,7,0,0,0,0],[6,0,0,1,9,5,0,0,0],[0,9,8,0,0,0,0,6,0],[8,0,0,0,6,0,0,0,3],[4,0,0,8,0,3,0,0,1],[7,0,0,0,2,0,0,0,6],[0,6,0,0,0,0,2,8,0],[0,0,0,4,1,9,0,0,5],[0,0,0,0,8,0,0,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
012345678053007000016001950002098000060380006000344008030015700020006606000028070004190058000080079
→
return
012345678053467891216721953482198342567385976142344268537915713924856696153728472874196358345286179
Moved or new

Fill the 51 blank cells while retaining all 30 givens. The returned board has each digit from 1 through 9 once in every row, column and aligned box.

Example 2

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],[0,0,0,0,0,0,0,0,0]]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
012345678053467891216721953482198342567385976142344268537915713924856696153728472874196358000000000
→
return
012345678053467891216721953482198342567385976142344268537915713924856696153728472874196358345286179
Moved or new

The first eight rows are complete. Each column is missing exactly the digit shown in the last row of the returned board, so all nine blanks are forced.

Constraints

  • board has exactly 9 rows and exactly 9 columns in every row.
  • 0 <= board[r][c] <= 9; zero is a blank.
  • For this exercise, assume the nonzero givens are valid and the board has exactly one solution. Invalid or unsatisfiable boards are outside the input domain.

More JP Morgan Chase Online Assessment questions

  • Find Total CostOA · Seen Oct 2026
  • Minimum Meeting RoomsOA · Seen Oct 2026
  • Count Dropped RequestsOA · Seen Oct 2026
  • Maximize Minimum Deployment DifficultyOA · Seen Oct 2026
  • Task SchedulingOA · Seen Oct 2026
  • Substring RemovalOA · Seen Oct 2026
  • Maximum Game Board ScoreOA · Seen Sep 2026
  • Minimum Digit Changes Between String HalvesOA · Seen Sep 2026
  • Same Substring Within BudgetOA · Seen Sep 2026
  • Invert Ad Visibility BitsOA · Seen Aug 2026

Similar questions at other companies

  • Empty ShelfSquarepoint Capital · OASquarepoint Capital interview questions
  • Cave AdvantureMeta · OAMeta interview questions
  • Optimal Office PlacementRoblox · OARoblox interview questions
  • Word SearchBloomberg LP · OA · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Four-by-Four Boundary GridSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Rat in a Maze: All Simple PathsPeopleStrong · OAPeopleStrong interview questions
  • Find a Word Path Moving Right or DownIntuit · OAIntuit interview questions
  • Word Search IIAmazon · ONSITE INTERVIEW
  • Sudoku Puzzle SolverConfluent · PHONE SCREEN · ONSITE INTERVIEWConfluent interview questions
  • Choose the Next Minesweeper ActionRunloop · PHONE SCREEN

Interview reports that mention this question

  • JPMorgan Chase Intern Campus Rounds: 4 Experiences (Part 2 of 5)
  • JPMorgan Tech Intern Interviews: 43 Experiences (Part 1 of 5)

JP Morgan Chase interview experiences

  • JPMorgan Quant Stats Superdays: 3 Experiences (Part 3 of 3)
  • JPMorgan Quant Modeling Superdays: 7 Experiences (Part 2 of 3)
  • JPMorgan Quant Intern Superday: 19 Experiences (Part 1 of 3)
  • JP Morgan Chase Data and AI Intern Superday: 11 Experiences
All JP Morgan Chase interview questionsSee JP Morgan Chase hiring insights
Saved
class Solution {
    public int[][] solveSudoku(int[][] board) {
        // Write your code here.
    }
}
Checking account…