My understanding is above solution wont work if first node itself is merging node
Your understanding is incorrect, provided approach will work. Considering your example :
list1 = 1 -> 2 -> 3 -> 4 -> 5
list2 = 3 -> 4 -> 5
and node 3
is the intersection.
the difference d = 5 - 3 = 2,
after step 4) list1 will be forwarded by 2 and will point to 3 -> 4 -> 5
, so it will point to exactly same node as list2
, which will be revealed by first comparison perfromed at step 5).
Since you implement this in Java, to compare "element memory address" (from your proposal) you simply compare references, which will give you equality only if they refer ("point to") the same object.
Hope that helps.