Link: https://leetcode.com/problems/knight-dialer
Solution:
DSA: DP
Intuition
This is kind of a graph problem. Just do DFS with a cache for all possibilities and return 1 as the base case when length == n.
There is also a crazy math solution that I don’t really understand. Maybe memorize it if possible.
Implementation
This is the diagram from LC editorial:
Visual
Memory encoding
review