I believe the given Union solution breaks when one list is empty and the other has duplicates. The given union requirement is stated as:
" 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 but duplicates are not allowed."
So in that case the result will have duplicates.
Another issue is that it is not clear whether we should create a new list with new pointers or just reuse the pointers from the given list. Solution given is with the latter, but both seems to be reasonable and the question should have made it clear.
One last thing: the Intersection time complexity is vagally explained. I didn’t understand the max/min part. Please elaborate.
Type your question above this line.
Course: https://www.educative.io/collection/5642554087309312/5646276079124480
Lesson: https://www.educative.io/collection/page/5642554087309312/5646276079124480/5187211452481536