Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Validate Sudoku with Complexity
00:00
5 left

Validate Sudoku with Complexity

MediumPython

Problem

Code a solution to validate a Sudoku board and explain its time complexity.

Implement validate_sudoku(board), where board is a 9x9 list of strings. Each cell contains a digit from "1" to "9" or "." for empty. Return True if no digit is repeated within any row, column, or 3x3 sub-box; otherwise return False. The board does not need to be solvable or completely filled.

Constraints

  • board has exactly 9 rows and 9 columns
  • Each cell is a digit from "1" to "9" or "."
  • A board only needs to satisfy validation rules, not be solvable
  • Each digit must be unique within its row, column, and 3x3 sub-box

Function Signature

def validate_sudoku(board):
Interviewer

Your question is Validate Sudoku with Complexity. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.