Given a linked list of size N. The task is to complete the function countNodesinLoop() that checks whether a given Linked List contains loop or not and if loop is present then return the count of nodes in loop or else return 0.
Input(to be used for Expected Output Only):
First line of input contains number of testcases T. For each testcase, first line of input contains length of linked list and next line contains data of the linked list.
For each testcase, there will be a single line of output containing the length of loop in linked list, else print 0, if loop is not present in the linked list.
The task is to complete the function countNodesinLoop() which contains the only argument as reference to head of linked list.
1 <= T <= 100
1 <= N <= 500
25 14 19 33 10 21 39 90 58 45
Testcase 1: There is a loop of length 6 in the given linked list.