Tap here to switch tabs
Problem
Submissions

Problem: Check Knight Tour Configuration

med
30 min
Try to solve the Check Knight Tour Configuration problem.

Statement

An n×nn \times n integer matrix grid represents the sequential path of a knight on a chessboard. The value at grid[row][col] represents the step order at which the cell (row, col) is visited, starting from step 00.

A valid knight tour must satisfy the following conditions:

  • The knight must start at the top left cell (0, 0) at step 00.

  • For every step from kk to k+1k + 1 (where 0≤k<n×n−10 \leq k < n \times n - 1), the move must be a valid knight move. A knight moves two cells in one cardinal direction and one cell in the perpendicular direction.

Return true if grid represents a valid knight tour configuration, or false otherwise.

Constraints:

  • n ==== grid.length ==== grid[i].length

  • 3≤3 \leq n ≤7\leq 7

  • 0≤0 \leq grid[row][col] <n×n< n \times n

  • All integers in grid are unique.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Check Knight Tour Configuration

med
30 min
Try to solve the Check Knight Tour Configuration problem.

Statement

An n×nn \times n integer matrix grid represents the sequential path of a knight on a chessboard. The value at grid[row][col] represents the step order at which the cell (row, col) is visited, starting from step 00.

A valid knight tour must satisfy the following conditions:

  • The knight must start at the top left cell (0, 0) at step 00.

  • For every step from kk to k+1k + 1 (where 0≤k<n×n−10 \leq k < n \times n - 1), the move must be a valid knight move. A knight moves two cells in one cardinal direction and one cell in the perpendicular direction.

Return true if grid represents a valid knight tour configuration, or false otherwise.

Constraints:

  • n ==== grid.length ==== grid[i].length

  • 3≤3 \leq n ≤7\leq 7

  • 0≤0 \leq grid[row][col] <n×n< n \times n

  • All integers in grid are unique.