Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Can you please explain this part?# remove the current node from the path to back...

Jasman Arora

Aug 11, 2022

Can you please explain this part?

remove the current node from the path to backtrack,

we need to remove the current node while we are going up the recursive call stack.

del currentPath[-1] Why do we need to remove the current node in the end?

4

0

Comments
Comments
P
Paolo Tormon3 years ago

We are not removing the current node, we are removing the value of the current node.

Remember we are keeping track of all the nodes so far, but if that path reaches a dead end we should not consider that value anymore but maybe its parent and other child can be conside...

On this page