Interection point of two LL

Its giving wrong answer. whats error?

this approach will not work
because both LL are merged
initially the list is

1 -> 2 -> 3  -> null
   ↗
4

when you reverse first list it becomes

3 -> 2 -> 1  -> null
   ↗
4

you got 3 -> 2 -> 1

and then when you call reverse for second list
list becomes

3 -> 2 -> 4  -> null
   ↗
1

you got 1 2 4

hence you got two reverse list which are
3 2 1
1 2 4
which are incorrect

this is because two linked list are merged (actually same with 2 heads)

i hope you understand the flaws in this approach

1 Like