
Implement a function that decides whether a singly linked list eventually loops back onto itself or terminates with a NULL pointer.
detect_cycle(NULL)Expected result
0For your own tracking. Tests grade your code.
detect_cycle(head) // list: A -> B -> C -> NULLExpected result
0detect_cycle(head) // list: A -> B -> C -> D -> A (tail loops to head)Expected result
1Expected files
detect_cycle.cAllowed functions
None. Write every helper yourself.
Allowed headers

Implement a function that decides whether a singly linked list eventually loops back onto itself or terminates with a NULL pointer.
detect_cycle(NULL)Expected result
0For your own tracking. Tests grade your code.
detect_cycle(head) // list: A -> B -> C -> NULLExpected result
0detect_cycle(head) // list: A -> B -> C -> D -> A (tail loops to head)Expected result
1Expected files
detect_cycle.cAllowed functions
None. Write every helper yourself.
Allowed headers

Run the tests to grade your code
Build your code, then check each test here. Open a result to inspect its output.
v0.40: Create exercises. Challenge the community.
Meet Studio →