How can I use DFS for this problem ?
no. Bcoz u need to go greedy , so u need to move level by level. So BFS approach is the right approach
Yes. You can use DFS with Dynamic Programming
but it fails time limit
Just to find whether Knight can move to the destination or not we can use DFS approach, but to find the minimum number of steps for the knight to move, we have to use BFS.
why so ? can you plz explain ! I was calling dfs in all 8 directions for each cell that I reach and was then finding the minimum out of all 8 and then returning. My ans is partially accepted…so can you plz tell this concept. Thank you