Tap here to switch tabs
Problem
Submissions

Problem: Minimum Knight Moves

med
30 min
Try to solve the Minimum Knight Moves problem.

Statement

You are given two integers x and y representing a target coordinate on an infinite chessboard. A knight starts at coordinate [0,0][0, 0] and can move in an L shape: 22 squares in one direction and 11 square perpendicular, for a total of 88 possible moves from any position.

Return the minimum number of knight moves required to reach the coordinate [x,y][x, y] from [0,0][0, 0].

Constraints:

  • 300-300 \leq x, y 300\leq 300

  • 00 \leq |x+| + |y300| \leq 300

Tap here to switch tabs
Problem
Submissions

Problem: Minimum Knight Moves

med
30 min
Try to solve the Minimum Knight Moves problem.

Statement

You are given two integers x and y representing a target coordinate on an infinite chessboard. A knight starts at coordinate [0,0][0, 0] and can move in an L shape: 22 squares in one direction and 11 square perpendicular, for a total of 88 possible moves from any position.

Return the minimum number of knight moves required to reach the coordinate [x,y][x, y] from [0,0][0, 0].

Constraints:

  • 300-300 \leq x, y 300\leq 300

  • 00 \leq |x+| + |y300| \leq 300