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

0% completed

Vote For New Content
struggled with this question. missed having to find all sub paths of current no...

Interviews

Jan 13, 2022

struggled with this question. missed having to find all sub paths of current node and using reverse iterator to do this. Why doesn't a regular iterator work?

2

0

Comments
Comments
Design Gurus
Design Gurus4 years ago

Because we should find all the NEW paths as we added a new element; this can only be done if we include the last element added to every possible path.

If we use a forward iterator (which will start from the root), we will have duplicate paths as there can be intermedia...

On this page