On two occasions I have been asked [by members of Parliament]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. Charles Babbage
The singly linked list contains the sequence of nodes which each node contains data and link to the next node. Write a program to print the union and intersection of given two linked lists. The union link combines both linked list and return as singly linked list. The intersection list builds based on common nodes from both linked list.
Find Union and Intersection list 1: [11, 22, 33] Find Union and Intersection list 2: [22, 33, 44, 55, 66] Intersection of list1 and list2: [22, 33] Union of list1 and list2: [33, 66, 22, 55, 11, 44]