Please enter your email address or userHandle.
Given two linked lists, your task is to complete the function makeUnion(), that returns the union of two linked lists. This union should include all the distinct elements only.
L1 = 9->6->4->2->3->8
L2 = 1->2->8->6->2
Output: 1 2 3 4 6 8 9
The task is to complete the function makeUnion() which makes the union of the given two lists and returns the head of the new list.
Note: The new list formed should be in non-decreasing order.
Expected Time Complexity: O(N * Log(N))
Expected Auxiliary Space: O(N)
1<size of the linked lists<=5000
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Login to access your submissions.
Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.