PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates the ability to perform constraint validation on a fixed-size 9×9 grid, testing skills in matrix/array handling, duplicate detection and use of simple data structures for correctness checking.

  • medium
  • Verkada
  • Coding & Algorithms
  • Software Engineer

Validate a 9×9 grid under constraints

Company: Verkada

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem You are given a 9×9 grid representing a partially filled puzzle. Each cell contains either: - a digit character `'1'`–`'9'`, or - the character `'.'` meaning empty. Determine whether the current filled cells are **valid** under these rules: 1. No digit `'1'`–`'9'` repeats within any row. 2. No digit repeats within any column. 3. No digit repeats within any of the nine 3×3 sub-grids. Return `true` if the filled cells satisfy all rules; otherwise return `false`. ## Input / Output - **Input:** `board` — a 9×9 array of characters - **Output:** boolean ## Notes / Constraints - You only need to validate the currently filled cells; you do **not** need to solve the puzzle. - The board is always 9×9. ## Example If a row contains two `'5'` values (ignoring `'.'`), the board is invalid and you should return `false`.

Quick Answer: This question evaluates the ability to perform constraint validation on a fixed-size 9×9 grid, testing skills in matrix/array handling, duplicate detection and use of simple data structures for correctness checking.

You are given a 9×9 grid representing a partially filled puzzle. Each cell contains either a digit character '1' to '9' or '.' for an empty cell. Determine whether the currently filled cells form a valid state. A state is valid if no digit appears more than once in any row, any column, or any 3×3 sub-grid. You only need to validate the existing filled cells; you do not need to solve the puzzle.

Constraints

  • board always has exactly 9 rows and 9 columns
  • Each board[r][c] is either '.' or a character from '1' to '9'
  • Only the currently filled cells need to be validated

Examples

Input: ([['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']],)

Expected Output: True

Explanation: No filled digit repeats in any row, column, or 3×3 sub-grid.

Input: ([['5','3','.','.','7','.','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']],)

Expected Output: False

Explanation: Row 0 contains the digit '7' twice, so the board is invalid.

Input: ([['5','3','.','.','7','.','.','.','.'],['6','.','.','1','9','5','.','.','.'],['.','9','8','.','.','.','.','6','.'],['8','.','.','.','6','.','.','.','3'],['4','.','.','8','.','3','.','.','1'],['7','.','.','.','2','.','.','.','6'],['.','6','.','.','.','.','2','8','.'],['8','.','.','4','1','9','.','.','5'],['.','.','.','.','8','.','.','7','9']],)

Expected Output: False

Explanation: Column 0 contains the digit '8' twice, so the board is invalid.

Input: ([['5','3','6','.','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']],)

Expected Output: False

Explanation: The top-left 3×3 sub-grid contains the digit '6' twice, so the board is invalid.

Input: ([['.','.','.','.','.','.','.','.','.'],['.','.','.','.','.','.','.','.','.'],['.','.','.','.','.','.','.','.','.'],['.','.','.','.','.','.','.','.','.'],['.','.','.','.','.','.','.','.','.'],['.','.','.','.','.','.','.','.','.'],['.','.','.','.','.','.','.','.','.'],['.','.','.','.','.','.','.','.','.'],['.','.','.','.','.','.','.','.','.']],)

Expected Output: True

Explanation: An empty 9×9 board has no rule violations.

Hints

  1. Use separate hash sets to track which digits have already appeared in each row, column, and 3×3 box.
  2. A cell at row r and column c belongs to box index (r // 3) * 3 + (c // 3).
Last updated: Apr 24, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Merge Sorted Arrays In Place - Verkada (medium)
  • Find and Merge Camera Alert Intervals - Verkada (hard)
  • Find user who can access every camera - Verkada (medium)
  • Implement LRU and LFU caches - Verkada (medium)
  • Implement a recency cache and min-coins DP - Verkada (medium)