Given two Singly Linked List of N and M nodes respectively. The task is to check whether two linked lists are identical or not.
Two Linked Lists are identical when they have same data and with same arrangement too.
First line of input contains number of testcases T. For each testcase, first line of input contains length of linked lists N and M and next line contains elements of the linked lists.
For each test the output will be 'Identical' if two list are identical else 'Not identical'.
The task is to complete the function areIdentical() which takes head of both linked lists as arguments and returns True or False.
1 <= T <= 100
1 <= N <= 103
1 2 3 4 5 6
99 59 42 20
1 2 3 4 5
1 2 3 4 5
Testcase 1: Each element of first linked list is not equal to each elements of second linked list in the same order.
Testcase 2: Each element of first linked list is equal to each elements of second linked list in the same order.
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.