1197. Minimum Knight Moves

Problem

Find the minimum number of moves a knight needs to reach (x, y) on an infinite chessboard starting from (0, 0).

Given coordinates (x, y), find the minimum number of knight moves required to reach point (x, y) starting from origin (0, 0) on an infinite chessboard.

A knight moves in an L-shape: 2 squares in one direction and 1 square perpendicular, or 1 square in one direction and 2 squares perpendicular. The 8 possible knight moves are: (+2,+1), (+2,-1), (-2,+1), (-2,-1), (+1,+2), (+1,-2), (-1,+2), (-1,-2).

Examples
Input: [2,1]
Output: 1
Hints
Related Problems

1197. Minimum Knight Moves

Find the minimum number of moves a knight needs to reach (x, y) on an infinite chessboard starting from (0, 0).