In my opinion optimal solution for is by HASHING

(i:e) ist unsorted singly-linked list = m size

2nd unsorted singly linked list = n size

and we also create an single linked list called "Intersection" where we store our "result"

if m > n

we create a hash table of n size

1) one time traverse the whole linked list(2nd linked list) and insert it into the hash table

2) linearly traverse the ist linked list and for each elements we check whether it's leads collision in the hash table or not ?

whenever there's a collision occurs we insert that element in out intersection linked list

2 times just linear traverse the linked list , therefore time complexity : O(m+n)

At max every elements in the list "m" is also present in the list "n"

So Worst case space complexity : O(m)

(i:e) ist unsorted singly-linked list = m size

2nd unsorted singly linked list = n size

and we also create an single linked list called "Intersection" where we store our "result"

if m > n

we create a hash table of n size

1) one time traverse the whole linked list(2nd linked list) and insert it into the hash table

2) linearly traverse the ist linked list and for each elements we check whether it's leads collision in the hash table or not ?

whenever there's a collision occurs we insert that element in out intersection linked list

2 times just linear traverse the linked list , therefore time complexity : O(m+n)

At max every elements in the list "m" is also present in the list "n"

So Worst case space complexity : O(m)