# 1197. Minimum Knight Moves

<https://leetcode.com/problems/minimum-knight-moves>

## Description

In an **infinite** chess board with coordinates from `-infinity` to `+infinity`, you have a **knight** at square `[0, 0]`.

A knight has 8 possible moves it can make, as illustrated below. Each move is two squares in a cardinal direction, then one square in an orthogonal direction.

![](https://assets.leetcode.com/uploads/2018/10/12/knight.png) Return *the minimum number of steps needed to move the knight to the square* `[x, y]`. It is guaranteed the answer exists.

**Example 1:**

```
**Input:** x = 2, y = 1
**Output:** 1
**Explanation:** [0, 0] → [2, 1]
```

**Example 2:**

```
**Input:** x = 5, y = 5
**Output:** 4
**Explanation:** [0, 0] → [2, 1] → [4, 2] → [3, 4] → [5, 5]
```

**Constraints:**

* `-300 <= x, y <= 300`
* `0 <= |x| + |y| <= 300`

## ac

```java
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jaywin.gitbook.io/leetcode/solutions/1197-minimum-knight-moves.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
