Number of Moves

Problem Overview

  • Determine the minimum number of knight moves from start (row, col) to end on an n×n chessboard, or return -1 if unreachable.
  • Input: n (4–150), startRow, startCol, endRow, endCol with 0 ≤ values < n; Output: single integer moves or -1.
  • Domain: chessboard pathfinding; all moves must stay within board bounds.
  • From Citadel interviews; a classic coding interview problem and practical interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: