5 kyu
Can you get the loop ?
1,253 of 29,672Devouring
Description:
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 `next' method to get the following node.
node.next
Notes:
- do NOT mutate the nodes!
- in some cases there may be only a loop, with no dangling piece
Thanks to shadchnev, I broke all of the methods from the Hash class.
Don't miss dmitry's article in the discussion after you pass the Kata !!
Algorithms
Linked Lists
Performance
Similar Kata:
Stats:
Created | Dec 11, 2013 |
Published | Dec 12, 2013 |
Warriors Trained | 99486 |
Total Skips | 25452 |
Total Code Submissions | 235369 |
Total Times Completed | 29672 |
Ruby Completions | 1253 |
JavaScript Completions | 8719 |
Python Completions | 9886 |
Java Completions | 4995 |
Haskell Completions | 656 |
C# Completions | 2272 |
PHP Completions | 557 |
Kotlin Completions | 452 |
C++ Completions | 1755 |
C Completions | 651 |
Total Stars | 2060 |
% of votes with a positive feedback rating | 88% of 3112 |
Total "Very Satisfied" Votes | 2496 |
Total "Somewhat Satisfied" Votes | 464 |
Total "Not Satisfied" Votes | 152 |