Identical Linked Lists
Submissions: 12562   Accuracy:

51.37%

  Difficulty: Basic   Marks: 1

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.

Input:
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.

Output:
For each test the output will be 'Identical' if two list are identical else 'Not identical'.

User Task:
The task is to complete the function areIdentical() which takes head of both linked lists as arguments and returns True or False
.

Constraints:
1 <= T <= 100
1 <= N <= 103

Example:
Input:

2
6
1 2 3 4 5 6
4
99 59 42 20
5
1 2 3 4 5
5
1 2 3 4 5

Output:
Not identical
Identical

Explanation:
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.

 

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Harshit Sidhwa
Author: harshitsidhwa


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.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.