Are we not supposed to return common node?


#1

I have completed the function as per requirement said the problem statement. but, when I test my code am getting like below

There are 3 lines in the input

Line 1 ( Corresponds to arg 1 ) : Nodes in the non-overlapping part of the first linked list. First number S is the number of nodes. Then S numbers follow indicating the val in each of the nodes in sequence
For example, LinkedList: “1 --> 2” will be written as “2 1 2”(without quotes).

Line 2 ( Corresponds to arg 2 ) : Nodes in the non-overlapping part of the second linked list. First number S is the number of nodes. Then S numbers follow indicating the val in each of the nodes in sequence
For example, LinkedList: “3 --> 4 --> 5” will be written as “3 3 4 5”(without quotes).

Line 3 : Nodes in the overlapping part of both the linked list occurring as the suffix of the lists.
For example, LinkedList: “8 --> 9 --> 7” will be written as “3 8 9 7”(without quotes).

The lists are constructed by appending the overlapping nodes to the non-overlapping list.

I could not understand this. Do we need to read the input as well in the function? Arguments passed to the function getIntersectionNode() are not head nodes of the lists?

Someone, please help me understand this?

Thanks in advance!


#2

You need to return the head of the common node.
i.e
if two linked lists are as ::
1->2->3->4->5
and
7->8->3->4->5

3->4->5 should be returned…i.e the pointer to 3 should be returned