Given a linked list, remove the loop if it exists.
You need to find the last node of the list that points to one of its previous nodes and make it point to NULL.
First line contains âTâ, denoting the number of independent test cases.
For each test case, the input has three lines:
For each test case, it contains a line with n space space-separated integers denoting elements of the linked list.
5
3
3 4 5
1
5
1 2 3 4 5
2
4
67 54 890 32
4
2
23 45
-1
0
-1
3 4 5
1 2 3 4 5
67 54 890 32
23 45
1 <= T <= 100
0 <= n <= 1000
1 <= node elements <= 105