Coding Assessment Software Engineer Reported March 2026
On an unbounded chessboard whose coordinate values range from -infinity through +infinity, a knight begins at [0, 0].
The knight has 8 legal move patterns: [+/-1, +/-2] and [+/-2, +/-1].
Determine the smallest number of moves required for the knight to reach [x, y]. A reachable solution is guaranteed.
Example 1:
Input: x = 1, y = 2
Output: 1
Explanation:
A knight can arrive at [1, 2] in one legal move.
Example 2:
Input: x = 4, y = 4
Output: 4
Explanation:
The destination [4, 4] can be reached in four moves, and no shorter route is possible.
Example 3:
Input: x = 0, y = 0
Output: 0
Explanation:
Since the knight is already positioned on the destination, it does not need to move.
-300 <= x, y <= 3000 <= |x| + |y| <= 300This has been reported as a LeetCode-style online-assessment prompt for software engineer applicants.