Can I use DFS approach for this question?

programming
Tags: #<Tag:0x00007f182b14c388>

#1

How can I use DFS for this problem ?


#2

no. Bcoz u need to go greedy , so u need to move level by level. So BFS approach is the right approach


#3

Yes. You can use DFS with Dynamic Programming


#4

but it fails time limit


#5

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.


#6

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 :slight_smile: