Challenge: Union of Linked Lists
In this lesson, you will revisit another challenge from linked list chapter.
We'll cover the following
Problem Statement
Let’s revisit the definition of Set Union.:
Union
Given two lists A and B; the union is the list that contains elements or objects that belong to either A, or to B, or to both.
The union
function will take two linked lists and return their union.
Input
Two linked lists.
Output
A list containing the union of the two lists.
Sample Input
list1 = 10->20->80->60
list2 = 15->20->30->60->45
Sample Output
union = 45->30->15->10->20->80->60
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.