FastPrepMinimum Moves for Two Knights to Meet
Problems/Minimum Moves for Two Knights to Meet

Minimum Moves for Two Knights to Meet

Amazon logoAmazon● MediumFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Amazon full-time onsite interview. The report gives an endless board, two knights that take turns with normal moves, the goal of meeting, and follow-ups about doing it faster. We added limits on the coordinates. Our version is about 99% the same as the reported question.

Two knights start at coordinates first = [x1, y1] and second = [x2, y2] on an infinite chessboard. They take turns, and the first knight moves first. On its turn, a knight must make one standard knight move: two squares along one axis and one square along the other.

Return the minimum total number of moves until both knights stand on the same square. If they already share a square, return 0.

Function

minimumKnightMeetingMoves(first: int[], second: int[]) → int

Examples

Example 1

first = [0,0]second = [1,2]return = 1

The first knight can reach the second knight in one move.

Example 2

first = [0,0]second = [1,0]return = 3

The second knight starts one square to the right of the first. One or two knight moves can never close a one-square gap, but three moves can. The first knight jumps two right and one up. The second knight jumps one left and two up. Then the first knight jumps two left and one up, landing on the second knight. So the answer is three.

Example 3

first = [7,-4]second = [7,-4]return = 0

The knights start on the same square, so no moves are needed. The answer is zero.

Constraints

  • first.length == second.length == 2
  • -10^9 <= first[i], second[i] <= 10^9

More Amazon Onsite Interview questions

  • Assign Escalations to TeamsONSITE INTERVIEW · Seen Nov 2026
  • Best Time to Buy and Sell StockONSITE INTERVIEW · Seen Nov 2026
  • Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Maximum Earnings Across WarehousesONSITE INTERVIEW · Seen Nov 2026
  • Priority Message BufferONSITE INTERVIEW · Seen Nov 2026
  • Search in a Rotated Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent ElementsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Maximal SquareONSITE INTERVIEW · Seen Nov 2026
  • Serialize and Deserialize a Binary TreeONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Unit Conversion Across Independent FamiliesApple · PHONE SCREENApple interview questions
  • Smallest Binary-Digit MultipleMyntra · ONSITE INTERVIEWMyntra interview questions
  • Frog Position After T SecondsInMobi · PHONE SCREENInMobi interview questions
  • Minimum Steps with Double and Floor-DivideBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Tree Path GCDNewton School · PHONE SCREEN
  • Count Reachable Values by Halving and DecrementingInfosys · OAInfosys interview questions
  • Count Level-Order Traversals of a TreeBank of America · OABank of America interview questions
  • Reaching Points with Perfect-Square ObstaclesIMC Trading · OAIMC Trading interview questions
  • Broken CalculatorNutanix · OANutanix interview questions
  • Count Pasture Animal ArrangementsIntuit · OAIntuit interview questions

Amazon interview experiences

  • Amazon Experienced SDE Onsite Questions: 1 Experience
  • Amazon SDE Onsite Interview Questions: 9 Experiences
  • Amazon SDE II and L5 FDE Interview Questions: 4 Experiences
  • Amazon Full-Time OA Problems, Earlier Reports (Part 5 of 5)
  • Amazon Full-Time OA Problems, Recent Reports (Part 4 of 5)
  • Amazon New Grad OA Problems: Every Task We Have (Part 3 of 5)
See Amazon hiring insights
Saved
class Solution {
    public int minimumKnightMeetingMoves(int[] first, int[] second) {
        // Write your solution here.
    }
}
Checking account…