FastPrepCheck a Partly Filled Sudoku Grid
Problems/Check a Partly Filled Sudoku Grid

Check a Partly Filled Sudoku Grid

Expedia logoExpedia● MediumINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: An entry dated August 2021, from an Expedia SDE intern campus process in New Delhi, lists this task by name without saying which round it came from.

The entry gives no rules, input format or examples. Here, you get a 9 x 9 grid of characters where each cell is a digit from 1 to 9 or a dot for an empty cell. You return true when no row, column or 3 x 3 box holds the same digit twice. Empty cells are ignored, and the board does not need to be solvable.

Our version is about 90% the same as the reported question.

You are given a 9 x 9 Sudoku board board. Each cell holds a digit from '1' to '9', or '.' when it is empty. Rows and columns are numbered from 0 to 8.

Return true if the filled cells break none of these rules, and false otherwise:

  • No row holds the same digit twice.
  • No column holds the same digit twice.
  • No 3 x 3 box holds the same digit twice. The nine boxes are formed by rows 0 to 2, 3 to 5 and 6 to 8 crossed with columns 0 to 2, 3 to 5 and 6 to 8.

Only the filled cells are checked. Empty cells never break a rule, and the board does not need to be solvable.

Function

isValidSudoku(board: char[][]) → boolean

Examples

Example 1

board = [["1",".",".","2",".",".","4",".","."],[".","5",".",".",".",".",".","7","."],[".",".","8",".",".","6",".",".","9"],["7",".",".","5",".",".",".",".","."],[".",".",".",".","8",".",".","6","."],[".",".","1",".",".","2",".",".","."],["6",".",".",".",".",".","8",".","."],[".","4",".",".","1",".",".","2","."],[".",".","7",".",".",".",".",".","3"]]return = true
board
01234567801..2..4..1.5.....7.2..8..6..937..5.....4....8..6.5..1..2...66.....8..7.4..1..2.8..7.....3

Every filled cell holds a digit that appears only once in its row, once in its column and once in its 3 x 3 box. Empty cells are not checked, so the answer is true.

Example 2

board = [["1","8",".","2",".",".","4",".","."],[".","5",".",".",".",".",".","7","."],[".",".","8",".",".","6",".",".","9"],["7",".",".","5",".",".",".",".","."],[".",".",".",".","8",".",".","6","."],[".",".","1",".",".","2",".",".","."],["6",".",".",".",".",".","8",".","."],[".","4",".",".","1",".",".","2","."],[".",".","7",".",".",".",".",".","3"]]return = false
board
012345678018.2..4..1.5.....7.2..8..6..937..5.....4....8..6.5..1..2...66.....8..7.4..1..2.8..7.....3

This is the board from Example 1 with one more digit. The digit 8 now appears at row 0, column 1 and at row 2, column 2. These cells are in different rows and different columns, but both are in the 3 x 3 box made of rows 0 to 2 and columns 0 to 2, so the answer is false.

Example 3

board = [["1",".",".","2",".",".","4",".","."],[".","5",".",".",".",".",".","7","."],[".",".","8",".",".","6",".",".","9"],["7",".",".","5",".",".",".",".","."],[".",".",".",".","8",".",".","6","."],[".",".","1",".",".","2",".",".","."],["6",".",".",".",".",".","8",".","."],[".","4",".",".","1",".",".","2","."],[".","5","7",".",".",".",".",".","3"]]return = false
board
01234567801..2..4..1.5.....7.2..8..6..937..5.....4....8..6.5..1..2...66.....8..7.4..1..2.8.57.....3

This is the board from Example 1 with one more digit. The digit 5 now appears twice in column 1: at row 1 and at row 8. They are in different boxes, but a column may not hold a digit twice, so the answer is false.

Constraints

  • board.length == 9
  • board[i].length == 9
  • board[i][j] is a digit from '1' to '9' or '.'.

More Expedia Onsite Interview questions

  • Scramble StringONSITE INTERVIEW · Seen Sep 2026
  • Smallest Sufficient TeamONSITE INTERVIEW · Seen Sep 2026
  • Check Anagram Pairs Index by IndexONSITE INTERVIEW · Seen Oct 2025
  • Fresh Oranges Left After Rotting StopsONSITE INTERVIEW · Seen Oct 2025
  • Longest Increasing SubsequenceONSITE INTERVIEW · Seen Oct 2025
  • Lowest Common Ancestor with Repeated and Missing ValuesONSITE INTERVIEW · Seen Oct 2025
  • Shortest Substring with Exactly K OnesONSITE INTERVIEW · Seen Oct 2025
  • Middle Element of a Linked ListONSITE INTERVIEW · Seen Nov 2024
  • Minimum in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Sep 2024
  • Mirror Image Binary TreesONSITE INTERVIEW · Seen Sep 2024

Similar questions at other companies

  • Sudoku Board ValidationConfluent · PHONE SCREEN · ONSITE INTERVIEWConfluent interview questions
  • Validate Rectangular Game PiecesGoogle · ONSITE INTERVIEWGoogle interview questions
  • Set Matrix ZeroesMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Query Whether an Island Size ExistsMeta · ONSITE INTERVIEWMeta interview questions
  • Validate a Sudoku BoardZipRecruiter · ONSITE INTERVIEWZipRecruiter interview questions
  • Cache Shared Image Pipeline PrefixesAnthropic · ONSITE INTERVIEWAnthropic interview questions
  • Sparse Matrix MultiplicationByteDance · PHONE SCREENByteDance interview questions
  • First Completed Mingo LineEpic · OAEpic interview questions
  • Valid SudokuVerkada · PHONE SCREENVerkada interview questions
  • Count 2x2 Submatrices by Black CellsTikTok · OATikTok interview questions

Expedia interview experiences

  • Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
  • Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
  • Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
  • Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
  • Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)
  • Expedia SWE Intern Final Round: 126 Experiences (Part 1 of 6)
All Expedia interview questionsSee Expedia hiring insights
Saved
class Solution {
    public boolean isValidSudoku(char[][] board) {
        // Write your code here.
    }
}
Checking account…