Given a singly linked list. The task is to find the length of linked list, where length is defined as number of nodes in the linked list.
First line of input contains number of testcases T. For each testcase, first line of input contains number of nodes N, to be inserted into the linked list and next line contains data of N nodes.
There will be a single line of output for each testcase, which contains length of the linked list.
1 <= T <= 30
1 <= N <= 100
1 <= value <= 103
Your task is to complete the given function getCount(), which takes head reference as argument and should return the length of linked list.
1 2 3 4 5
2 4 6 7 5 1 0
Testcase 1: Count of nodes in the linked list is 5, which is its length.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.