This is my approach to the question. I take input from the user and then through a recursive function go through all the possible ways in which the knight can move and as it moves i make the cell as 0. Then outside the function I check if there is any 1 remaining, and count the number remaining and print that as the output, but the code doesn’t work for all the test cases.
Confusion with the code
there needs to be just 1 thing added in the code
u are not measuring the max no of steps that knight takes in any of his journey
u need to keep track of that
refer this code for that purpose
I’ve added a count variable and ans variable but still the code doesn’t work for all the test cases.
—> another doubt is that why do we put cnt+1 in the max function instead of just cnt.
—> For some reason the exact same code gives output 0 in codeblocks ide and doesn’t work for a single test case.
please cross check with my code
my code gives all correct
I cannot help unless I have ur code
this is the code
added comment
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.