pl tell the mistake in the code
Intersection point of ll
hey @ayush15goel, you are considering that linked List 1 is always of greater that Linked list 2 (check line 206), But Linked list 2 can be of greater length too. Please consider this case also.
Sir,I will consider that case but currently it is always giving -1.Pl tell the mistake in the current code.
hey @ayush15goel, in Line no 214, make head2!=NULL also along with head1. If if condition of line 216 is true, not only print the result but also break from loop. You are getting -1 beacuse you are still checking ahead even you got your required condition.So break is important.
I have made the changes and mentioned them as change in comments.
Donβt forget to consider other case also that I have told you earlier.
sir it is showing -1 even when the link lists intersect.Pl tell how to resolve it.
hey @ayush15goel, your code has cout<<-1 is outside the while loop, thatswhy it printed everytime. A flag can be used to resolve it. https://ide.codingblocks.com/s/90374
thank you so much sir.Code working now .