You are given an n x n grid of cells with 0-indexed coordinates (r, c), 0 <= r, c <= n - 1. A piece stands on cell (r1, c1) and moves like a chess knight: in one step it changes one coordinate by 2 and the other by 1 (all eight combinations of signs and axes), as long as it stays on the grid.
Return the minimum number of steps needed to reach cell (r2, c2), or -1 if it cannot be reached.
Note that the start and target may coincide (0 steps), and that on very small grids some cells are unreachable. For example, on a 3 x 3 grid the center cell has no knight moves at all.
Input: n = 8, r1 = 0, c1 = 0, r2 = 7, c2 = 7
Output: 6
Explanation: On the standard 8 x 8 board, six knight steps are needed between opposite corners.
Input: n = 8, r1 = 0, c1 = 0, r2 = 1, c2 = 2
Output: 1
Explanation: (1, 2) is one knight step from (0, 0).
Input: n = 3, r1 = 0, c1 = 0, r2 = 1, c2 = 1
Output: -1
Explanation: The center of a 3 x 3 grid cannot be reached; no knight step lands there.
n ≤1000r1, c1, r2, c2 ≤ n −1