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.
- Time : O(mlogm + nlogn)
Space : O(1)
merge sort solution
c++
1 | struct Node *mergeSort(struct Node *head) { |
- Time : O(klogk)
Space : O(k)
hash table solution
c++
1 | struct Node *mergeSort(struct Node *head) { |