TooWeak_TooSlow's blog

By TooWeak_TooSlow, history, 6 years ago, In English

Hello Everyone, I am trying to solve this problem. but not able to come up with a solution. can someone help me with solving the problem any approach/hint.

Problem Statement: Given a square chessboard of N x N size, the position of Knight and position of a target is given. We need to find out minimum steps a Knight will take to reach the target position. Only Perpendicular Moves Are Allowed.

Constraints:

1<=N<=150. 0<=StartX<=64 0<=StartY<=64

0<=EndX<=64 0<=EndY<=64

StartX and StartY Indicate Starting Location. EndX and Endy Indicate Ending Location.

Test Case:

Input:

N=8 startX and StartY = 0,5

endX and endY = 6,5

output: 3

Full text and comments »