Funky chess board

In this problem we have to find the number of places the knight cannot visit right?
So for that first we have to find the number of places the knight can visit by setting it to 0, then while backtracking the place where the knight cannot visit we set it as 1.
This is the approach right?
But one thing i didnt understand was the count of the knights.


This is what i coded but after the base case
the variable ans=max(ans,count+1) is what i fail to understand. what is the logic behind this count function in this problem.

In the main the count is used to find the total no, of inputs right? but what is it in the recursive function?

Hello @mkidwai74 we are incrementing the count to find how many totak number of blocks the knight can move.
so for that you have to to increment the count for every valid move of the knight. so inorder to maintain the count we have to increment it in every recursion call.

So the count in the main function is total o, of inputs??
and if we subtract it with the total no, of blocks the knight can move we get the the count of the knights that cannot move??
Also is the approach that i described above for the problem correct?? Like is that is what is happening in the code?

@mkidwai74 yes you are right.
you are confused because in main you have declared the count and the in the fucntion also you have declared the count but the working of both them are different.
check this:


in main we are just counting the blocks that are available and in the fucntion above we are counting the number of boxes the knight can visit.

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.