hey why dont you keep a track of all node addresses, then when they start repeating break.
But before you break allow just the current node that signalled "hey, am already on the list". That node is your head to the loop.
NB: Just allow one node's address to repeat.
hey why dont you keep a track of all node addresses, then when they start repeating break.
But before you break allow just the current node that signalled "hey, am already on the list". That node is your head to the loop.
NB: Just allow one node's address to repeat.
woow, thanks alot i didnt even know this.
have replaced the
occurrences = Hash.new(0)
withoccurrences = {}
.It throws an error and i dont understand why, who can explain the reason?