i am not getting answer , please help.
Thank You
Please review my code and tell my mistake
you ll get null pointer exception for input like:
136 916 769 801 96 656 105 742 839 10 192 643 523 988 479 812 455 934 735 754 876 897 220 570 739 141 605 9 303 398 936 727 649 636 819 161 179 59 193 828 808 375 945 111 3 724 525 688 520 918 466 497 73 629 467 300 490 547 83 773 567 536 -1
768 884 421 280 842 644 744 224 100 782 511 861 493 258 477 103 395 650 374 313 679 21 604 857 985 556 803 954 809 24 551 405 241 647 869 320 545 886 208 900 982 234 445 294 394 798 540 871 459 872 672 521 560 134 495 783 895 376 739
try this approach :
Node intersectionOfTwoLinkedLists(Node l1, Node l2) {
if (l1 == null || l2 == null)
return null;
Node a = l1;
Node b = l2;
while (a != b) {
a = a == null ? l1 : a.next;
b = b == null ? l2 : b.next;
}
return a;
}
sorry , but itβs also not working
here, this is the complete code
if this solves your doubt please mark it as resolved 
1 Like
Thank you mam

1 Like