5 unsigned int totalCycleLength = 0;
6 for (
int i = 0; i < n; i++) {
9 ListNode * singleIncrement = &arrPtr[i];
10 ListNode * doubleIncrement = &arrPtr[i];
12 if (singleIncrement->
next == NULL || doubleIncrement->
next == NULL) {
15 if (singleIncrement == doubleIncrement->
next) {
19 while (cycleIncrement != singleIncrement) {
21 cycleIncrement = cycleIncrement->
next;
23 totalCycleLength += cycleLength;
26 singleIncrement = singleIncrement->
next;
27 doubleIncrement = doubleIncrement->
next->
next;
30 return (
double) totalCycleLength / n;