Intersection of two linked list - leetcode

ques ->https://leetcode.com/problems/intersection-of-two-linked-lists/
ide->https://ide.codingblocks.com/s/204962

what is the problem in the code

@mikkyimran
hello Imran,
image

dont compare node val ,compare addresses in pointer so above line should be

if(headA==headB )

why compare address and if we compare address why it is giving value at 8 but not at 1 ?
As 1 is present in both linked lists

image

the number written on node is data and not there adrresses.

u can see in above figure that 1 in B is equal to 1 in A but they are not intersecting ( having same value is not sufficient condition for intersection).
for intersection nodes should have same addresses (in the figure it is 8).

1 Like

Thanks @aman212yadav for the explanation