11. Steps by Knight
Medium

Problem Statement

Given a square chessboard of size N x N, the initial position of a Knight and the position of a target. Find out the minimum steps a Knight will take to reach the target position.

Examples

1Example 1
Input:
{ "KnightPos": [ 4, 5 ], "TargetPos": [ 1, 1 ], "N": 6 }
Output:
3
2Example 2
Input:
{ "KnightPos": [ 1, 1 ], "TargetPos": [ 1, 1 ], "N": 4 }
Output:
0
3Example 3
Input:
{ "KnightPos": [ 1, 1 ], "TargetPos": [ 2, 2 ], "N": 4 }
Output:
4
Loading...

Sign in to Run Code and Submit