5 kyu
Can you get the loop ?
1,251 of 29,445Devouring
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 | 98824 |
Total Skips | 25328 |
Total Code Submissions | 234640 |
Total Times Completed | 29445 |
Ruby Completions | 1251 |
JavaScript Completions | 8677 |
Python Completions | 9778 |
Java Completions | 4974 |
Haskell Completions | 652 |
C# Completions | 2263 |
PHP Completions | 549 |
Kotlin Completions | 446 |
C++ Completions | 1727 |
C Completions | 642 |
Total Stars | 2046 |
% of votes with a positive feedback rating | 88% of 3100 |
Total "Very Satisfied" Votes | 2486 |
Total "Somewhat Satisfied" Votes | 462 |
Total "Not Satisfied" Votes | 152 |