Two test case failing

what’s wrong with my approach?

if you think I should backtrack, why so?

Thank you.

hello @prateek_5 if you doubt that you dont have to bactrack in this question then please read the question again .
and try to understand it again .
please reply after reading the question again .
we will discuss here if you still have doubt .
Happy Learning !!

Please elaborate :pray:

@prateek_5 suppose it is at the starting point and the recursion call will go on until it returns from the recursion call and if at any point when it is returning from the recursion call there is possible way to go at certain location but you will not backtrack then you will miss out that case and suppose if there is no possible way further then you will miss out the case in the way like when you are traversing you are marking that index as 1 and if you dont backtrack (i.e if you dont mark it as 0 again) then it will not make further calls for possible cases.
that is the need to backtrack in this case .
i hope i have cleared your doubt .
Happy Learning !!

The only issue was in comprehending the line “in any number of moves without resting in any square more than once? Minimize this number.”

THIS IS WHAT I UNDERSTOOD. Correct me if I got something wrong.

It means You have to cover max number of boxes in single traversal(one continuous move until to can’t move anymore).

suppose I started moving, now in one traversal, I covered 14 out of 24 valid boxes. Now I will backtrack again to initial position and start afresh along (one of those 8 valid movements for a knight). Now suppose I covered 16 out of valid 24 valid boxes. We will keep repeating this and storing the max out of the boxes covered in each traversal (14,16,…).

Now after exhausting all the possible moves, we have the value of max boxes that we could cover in a single (non-stop) move. We will subtract this max value from the total valid boxes on the board to get the number of boxes that we couldn’t move to(This value would be the minimum out of all possible traversals that we made).

Thank you.

hello @prateek_5 if you are traversing throught the board and then if you can traverse maximum of 16 possible moves in total of 24 after backtracking then yes it will be the anwer .
i hope i have cleared your doubt .
please mark this doubt as resolved.
Happy Learning !!

1 Like