Am i doing right? becoz i guess logic error
I`ll help you out, wait for a while till i debugg your code
there`s some shortcoming in your logic, refer to the below code for better understanding
mam samjh nhi aaya …jo aapne count+1 kara hua h , and hi=max() vali condition bhi
see,
what is happening is that in each subsequent call u are increasing the no of steps that u are visiting, that is being signified by the count variable
max(hi, count +1 ) is being taken because we backtrack but at each position, we keep track of hi that is maximum no of cells we have traversed.
please refer to this video starting 53 minutes, watch the entire knight recursion problem
I have tried to explain the problem using the diagram
mam meine khudse try kiya h jo video aapne btai thi , uski help se , thoda dekhlo code kaha mistake hai
bro @Muskan-Gupta-598128740703036
i have tried to explain it using a well commented code, the above code approach i asked u to watch in the video was to see how the position are being updated but it cannot be used for this senario because we do not have a base condition that a total of n*n moves would be made since the board is not the conventional one,
please try to dry run the code, start with 3*3 matrix ,then make some cells 0 then try a dry run, u`ll understand how the dfs calls are being made,
i have attached a well commented code.
mam aap apna calling number de sakte ho???
fine mam ,understood
mam this is the question from gfg , can you tell me why i am getting wrong answer?
Hi, here the question demands the no of possible ways the other knights be placed keeping one of them static,
and this would require us to modify a code by a bit.
this is more of a mathematical question than applying any sort of recursion or backtracking
i am attaching the code here, have a look
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.
mam this ques from gfg , it is giving wrong ans on submission …but jabh neeche jis test case par galt show karra h ,usko custum input par daalkar run krri hu toh correct ans aara hai
this is my code solution
Hey @Muskan-Gupta-598128740703036
Can you please send your code on IDEONE for now
CB IDE is facing issues and I can’t see your code there
