FastPrepMinimum Knight Moves on a Finite Board
Problems/Minimum Knight Moves on a Finite Board

Minimum Knight Moves on a Finite Board

Expedia logoExpedia● MediumNEW GRADINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report uses an N by N board. We chose zero-based coordinates, -1 for unreachable, and the limits. Our version is about 97% the same as the reported question.

A knight starts at (startRow,startColumn) on a size by size board. Coordinates are zero-based. A move changes one coordinate by 2 and the other by 1, with either sign; every visited cell must stay on the board.

Return the minimum number of moves to reach (targetRow,targetColumn). Return -1 when unreachable, and 0 when start and target are the same.

Function

minimumKnightMoves(size: int, startRow: int, startColumn: int, targetRow: int, targetColumn: int) → int

Examples

Example 1

size = 8startRow = 0startColumn = 0targetRow = 1targetColumn = 2return = 1

One legal knight displacement reaches the target.

Example 2

size = 2startRow = 0startColumn = 0targetRow = 1targetColumn = 1return = -1

No knight move fits on a 2x2 board, and the target differs from the start.

Constraints

  • 1 <= size <= 100.
  • 0 <= startRow, startColumn, targetRow, targetColumn <= 99.
  • Every coordinate is smaller than size.

More Expedia Online Assessment questions

  • Balanced NumbersOA · Seen Aug 2026
  • REST API: Discounted PriceOA · Seen Aug 2026
  • Maximum Team SizeOA · Seen Mar 2026
  • Per-Domain Request LimiterOA · Seen Oct 2025
  • Count Equal-Frequency SubsequencesOA · Seen Mar 2025
  • Count Increasing Stock PeriodsOA · Seen Mar 2025
  • Get Minimum StepsOA · Seen Oct 2024
  • Rank Songs by PopularityOA · Seen Oct 2024
  • Calculate the SumOA · Seen Oct 2024
  • Get Maximum EfficiencyOA · Seen Oct 2024

Similar questions at other companies

  • Shortest Path Around Rectangular ObstaclesDRW · OADRW interview questions
  • House Bounds in a Ragged GridRippling · OA · PHONE SCREENRippling interview questions
  • Grid Path With the Most ClearanceDocuSign · OADocuSign interview questions
  • Maximum Damage PatchGecko Robotics · OA · PHONE SCREEN
  • Directed Path ExistenceUnity · OA
  • Rotting OrangesSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
  • Minimum Time to Spread Through a GridAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Max Area of Island Without Changing the GridFlexport · PHONE SCREENFlexport interview questions
  • Minimum Time to Rot All OrangesMicrosoft · ONSITE INTERVIEWMicrosoft interview questions

Interview reports that mention this question

  • Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
  • Expedia New Grad SDE Earlier Loops: 5 Experiences (Part 2 of 3)

Expedia interview experiences

  • Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
  • Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
  • Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
  • Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)
All Expedia interview questionsSee Expedia hiring insights
Saved
class Solution {
    public int minimumKnightMoves(int size, int startRow, int startColumn, int targetRow, int targetColumn) {
        // Write your code here.
    }

}
Checking account…