You are reading a single comment by @wence and its replies.
Click here to read the full conversation.
-
I appreciate the advice, I'm considering these interview practice 🙂
Would that not be more like a BFS though? I'm going to visit each neighbour before I visit any neighbours of neighbours right? Suppose you could insert into the stack instead. Not that it matters whether we use BFS/DFS in the problems we've had so far
frankenbike
A lot of stacks the past few days...
https://gist.github.com/wence-/500e1bc4633192ac6fee67433aedd974#file-day09-py and so on.
@frankenbike FWIW, your recursive implementation of DFS is not overly idiomatic in imperative languages, the usual approach is: