Minimum steps to reach target by a Knight Only Perpendicular Moves Allowed.

Revision en2, by TooWeak_TooSlow, 2018-09-25 10:41:43

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

Tags knight problem

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English TooWeak_TooSlow 2018-09-25 10:41:43 8
en1 English TooWeak_TooSlow 2018-09-25 10:40:44 762 Initial revision (published)