You have an n x n chessboard, and a knight starts at the top-left cell (0,0).
The knight must move in such a way that it visits every cell exactly once, following valid knight moves.
You are given an n x n matrix grid where:
Each cell contains a unique number from 0 to n*n - 1.
The number in a cell tells which step of the knight’s journey that cell was visited.
Check whether this matrix represents a valid knight tour.
Return true if the knight follows valid moves for every step; otherwise, return false.
Input: grid = [[0,5,8],[7,2,3],[4,9,1]]
Output: true
Explanation:
Starting from 0 → 1 → 2 → ... → 9 follows all valid knight moves.
Input: grid = [[0,4,7],[3,8,1],[6,2,5]]
Output: false
Explanation:
A move in the sequence is not a legal knight move.
Accepted:
Submission: