this is my code
1 test case is wrong
hi @tanjuljain19, you have little overdid your code like i don’t understand why you did if(moveno==n*n) i have corrected your code and simplified it , what i am doing is instead of finding minimum numbers of cells left unvisited , i am finding maximum number of cells that can be visited under given constraints
check this code :- https://ide.codingblocks.com/s/244271
i have explained with comments
In case of any doubt feel free to ask 
mark your doubt as resolved if you got the answer
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.