Determine the minimum number of bishop moves needed to move from one square to another on a chessboard, or report that it is impossible.
You are given a chessboard coordinate system and two squares: a starting square and a target square. A bishop moves diagonally, and in one move it may travel any distance along a diagonal.
Return the minimum number of bishop moves required to reach the target square from the starting square.
If the target cannot be reached by any sequence of legal bishop moves, return -1.
(r1, c1) and (r2, c2).0 if start and target are the same square.1 if the target is reachable in one bishop move.2 if the target is reachable but requires two moves.-1 if the target is unreachable.Example 1
Input
start = (0, 0), target = (2, 2)
Output
1
Explanation
The target lies on the same diagonal as the start, so one bishop move is enough.
Example 2
Input
start = (0, 0), target = (1, 2)
Output
-1
Explanation
The two squares have different colors, so a bishop can never move between them.
Example 3
Input
start = (0, 0), target = (1, 1)
Output
2
Explanation
The squares have the same color, but they are not on the same diagonal. A bishop can reach the target in two moves via an intermediate square.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.