← Questions
Follow one-way links to the endpoint or the last node before a loop
0
I was asked this
No reports yet. Sign in to say where you were asked it.
A network has nodes joined by one-way links, and each node links to at most one other node. Starting from a given node, follow the links and return the endpoint: the last node the walk reaches before running out of links. If the walk falls into a loop instead, return the last node visited before the loop closes, that is, before the walk would revisit a node.
Say how you detect the loop, and give the time and space of your approach.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding
