Tap here to switch tabs
Problem
Submissions

Problem: Minimum Bishop Moves to Reach Target

Minimum Bishop Moves to Reach Target gives starting and destination squares as two-element arrays on an eight-by-eight chessboard. Return the fewest bishop moves, or minus one if the target is unreachable.

Statement

You are given two integer arrays source and target, each of length 22, representing the starting position source and the destination position target of a bishop on an 8×88 \times 8 chessboard.

In a single move, a bishop can move any number of squares along any diagonal direction without leaving the board.

Return the minimum number of moves needed to move the bishop from source to target. If it is impossible to reach target, return −1-1.

Constraints:

  • source.length == target.length =2= 2

  • 1≤1 \leq sr, sc, tr, tc ≤8\leq 8, where source =[= [ sr, sc ]] and target =[= [ tr, tc ]]

  • source ≠\neq target

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Bishop Moves to Reach Target

Minimum Bishop Moves to Reach Target gives starting and destination squares as two-element arrays on an eight-by-eight chessboard. Return the fewest bishop moves, or minus one if the target is unreachable.

Statement

You are given two integer arrays source and target, each of length 22, representing the starting position source and the destination position target of a bishop on an 8×88 \times 8 chessboard.

In a single move, a bishop can move any number of squares along any diagonal direction without leaving the board.

Return the minimum number of moves needed to move the bishop from source to target. If it is impossible to reach target, return −1-1.

Constraints:

  • source.length == target.length =2= 2

  • 1≤1 \leq sr, sc, tr, tc ≤8\leq 8, where source =[= [ sr, sc ]] and target =[= [ tr, tc ]]

  • source ≠\neq target