Breadth-First Search pattern
Minimum Knight Moves
On an infinite chessboard with a knight starting at the origin, return the minimum number of knight moves needed to reach a given target square. Watch it run step by step, then write your own pseudocode and get it checked by AI.
- LeetCode 1197
- Medium
- 1 approach
Sign in with Google or GitHub and you land straight on this page. DSA comes with the all labs plan and every ChaiCode batch.
Breadth-First SearchLeetCode 1197
Medium
The approach
- 01 BFS over knight moves O(V)O(V) space
What you will learn
- How to read Minimum Knight Moves and spot the breadth-first search pattern in it
- BFS over knight moves: O(V) time, O(V) space
- The pseudocode for each approach, its line lit as the animation runs
- Practice: write your own pseudocode and get it checked
More Breadth-First Search
See Minimum Knight Moves run, step by step
Sign in and this page opens on the animation, with all 8 Breadth-First Search problems beside it.
DSA comes with the all labs plan and every ChaiCode batch.