Skip to content

Latest commit

 

History

History

can-you-get-the-loop

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

You are given a node that is the beginning of a linked list. This list contains a dangling piece and a loop. Your objective is to determine the length of the loop.

For example in the following picture the size of the dangling piece is 3 and the loop size is 12:

// Use the `getNext()` method to get the following node.
node.getNext()

Notes:

  • do NOT mutate the nodes!
  • in some cases there may be only a loop, with no dangling piece