ADAKNG - Editorial

Hey @shivam_2701
Thanks for asking your doubt.

You cannot use DFS to solve this problem as DFS does not give the shortest path between two points. let’s considered a test case :point_down:

1
3 3 3

let (x,y,z) be the z moves required to reach (x, y) from starting index.
so the DFS call be
(3,3,0) β†’ (4,3,1) β†’ (5,3,2) β†’ (6,3,3)
now form (4,3,1) β†’ (4,4,2) But you can reach (4,4) in 1 move ( (3,3,0) β†’ (4,4,1) ).DFS does not take care of shortest path because of this we cannot use dfs here.

Thanks Bro , Now it is clear since bfs goes level wise it find the answer in least steps thanks once again