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

Правка en1, от TooWeak_TooSlow, 2018-09-25 10:40:44

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

Теги knight problem

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский TooWeak_TooSlow 2018-09-25 10:41:43 8
en1 Английский TooWeak_TooSlow 2018-09-25 10:40:44 762 Initial revision (published)