Tap here to switch tabs
Problem
Submissions

Problem: Minimum Bishop Moves to Reach Target

Try to solve the Minimum Bishop Moves to Reach Target problem.

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 8imes88 imes 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

Try to solve the Minimum Bishop Moves to Reach Target problem.

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 8imes88 imes 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