Intersection of two given sorted Linked List

Problem Statement : Given two sorted linked list return a list with intersection of data stored in those two lists.

My concern here is that can we just do it using or manipulating pointer? What I am doing is that, I am creating a new list. Also, here’s one concept of dummy node which I am not getting.

Here is my solution

Hi Raghav
You can do it using manipulating pointers i.e. by altering pointers in one of the list to get the result instead of creating a new list.
But it should be given that you’re allowed to alter the original lists.
In your code you need to add dummy.next=NULL in your function.
Hope it helps
Give a like if you’re satisfied:)

Thank you @shivansh1498

No problem :slight_smile:
Do give a like.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.