Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Maximum Number of Moves to Kill All Pawns

XPChallenge Points: 30
levelLevel: Hard

You are given a 50 × 50 chessboard with one knight and several targets placed on it.
• The knight starts at position (kx, ky).
• You are also given a 2D array targets, where each targets[i] = [xi, yi] represents the coordinates of a target.
Two players, Alice and Bob, take turns making moves — with Alice going first.
On each turn:
1. The player chooses any target that still exists on the board.
2. The knight must capture that chosen target using the minimum possible number of knight moves.
3. The knight may pass over other targets but only captures the chosen one during that turn.
• Alice’s goal: maximize the total number of moves used in the game (sum of all moves across both players).
• Bob’s goal: minimize the total number of moves.
Return the maximum total number of moves that Alice can guarantee if both players play optimally.
A knight moves in an “L” shape:
Two squares in one cardinal direction, then one square in a perpendicular direction (8 possible moves total).

Example 1:

Input: kx = 2 ky = 3 targets = [[4, 4]]

Output: 3

Example 2:

Input: kx = 1 ky = 1 targets = [[2, 3], [4, 4], [5, 6]]

Output: 9

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result