Code link : https://ide.codingblocks.com/s/437362
Why is it failing for 2 test cases?
hello @deep4013
the result of all 8 directions will not get added.
instead u have to pick maxium among all those 8 directions.
also u need to set ur board[i][j]=1 again while returning from the function call.
check ur updated code here->
also u missed one more thing, starting position of knight is given (1,1)
But why to take the maximum isn’t it like DFS?
yeah but u cannot comeback to same point and continue new path.
thats why we r taking maximum among all 8 branches
Ok got it. But why to make board[i][j] = 1 again? Also if I mark this doubt as resolved it gets reopened by itself on page closing or refreshing.
we are backtracking so that we can look for any other path.
i will mark it resolve from my side.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.