We are given a linked list which contains a cycle. Detect that cycle and break it. Print the linked list after removing the cycle.
Input Format
The first line contains space separated integers. The integers are such that all the values are distinct but the value start repeating once the cycle gets completed. The list of integers given ends when -1 is input.
Constraints
n < 10^5 where n is the length of list without the cycle
Output Format
Output single line containing space separated integers representing the list
Sample Input
1 2 3 4 5 2 3 -1
Sample Output
1 2 3 4 5
solution link: https://ide.codingblocks.com/s/294190
shows segmentation fault
what is wrong in the code?