Remove a cycle
Input
[3,2,0,-4], 1
Output
[3, 2, 0, -4]
The original list had a cycle; after removal the list becomes linear and converting back yields the same value sequence.
Full lesson preview
Detect and remove a cycle from a singly linked list (if one exists) and return the linearized list values.
Problem statement
Task
Examples
Input
[3,2,0,-4], 1
Output
[3, 2, 0, -4]
The original list had a cycle; after removal the list becomes linear and converting back yields the same value sequence.
Input format
Output format
Constraints
Samples
Input
[3,2,0,-4], 1
Output
[3,2,0,-4]
Cycle removed and values returned.