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

0% completed

Vote For New Content
Much like one of the earlier questions. A matrix isn't required to keep track of...

CaptainKidd

Dec 15, 2022

Much like one of the earlier questions. A matrix isn't required to keep track of where you have been. Just set the grid value to something not used like 2 and add an extra if check inside the recursive call for DFS to save memory.

0

0

Comments
Comments
Design Gurus
Design Gurus3 years ago

Yes, all of these questions can be done without the visited matrix.

On thing though, changing the input is not acceptable sometimes. Mostly, the function we write is expected to restore the input to its original farm. If you can't do it, then it is considered that you ...

On this page