Given two Linked Lists, find the first common element between given linked list i.e., we need to find first node of first list which is also present in second list.
Input : List1: 10->15->4->20 Lsit2: 8->4->2->10 Output : 10 Input : List1: 1->2->3->4 Lsit2: 5->6->3->8 Output : 3
We traverse first list and for every node, we search it in second list. As soon as we find an element in second list, we return it.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Construct a Maximum Sum Linked List out of two Sorted Linked Lists having some Common nodes
- Create a linked list from two linked lists by choosing max element at each position
- Longest common suffix of two linked lists
- Find count of common nodes in two Doubly Linked Lists
- Remove the common nodes in two Singly Linked Lists
- In-place Merge two linked lists without changing links of first list
- Find common elements in three linked lists
- Create new linked list from two given linked list with greater element at each node
- Count of lists which are not a subset of any other given lists
- Count items common to both the lists but with different prices
- Compare two strings represented as linked lists
- Merge two sorted linked lists such that merged list is in reverse order
- Subtract Two Numbers represented as Linked Lists
- Multiply two numbers represented as linked lists into a third list
- Union and Intersection of two linked lists | Set-2 (Using Merge Sort)
- Union and Intersection of two linked lists | Set-3 (Hashing)
- Count pairs from two linked lists whose sum is equal to a given value
- Sorted merge of two sorted doubly circular linked lists
- Check if two Linked Lists are permutations of each other
- Count pairs from two linked lists whose product is equal to a given value
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.