Find intersection of two linked lists using C++ program
belongs to collection: Data Structure programs using C and C++ (Sorting Programs)
All Answers
total answers (1)
belongs to collection: Data Structure programs using C and C++ (Sorting Programs)
total answers (1)
Brute force approach:
One technique can be to traverse all the nodes of a linked list and check whether the traversed node is in the other linked list or not. Such an approach takes O(m*n) times complexity. m, n=length of linked lists.
Efficient approach:
Efficient approach use to use merge sort.
C++ implementation to find intersection of two linked lists
Output
Example with explanation: