Hacker News new | ask | show | jobs
by kirab 3548 days ago
Should every node's value be printed out exactly once and if so, are there nodes which have two parents?

If so, I would keep the pointers in a set to mark nodes as processed but is there a more elegant solution?

2 comments

I would explicitly tell them that you should revisit nodes, and give them a few examples illustrating that point -- so all they needed to do was traverse edges.
Each node is an object and has a "checked" variable.