Please help me with my code. It’s passing for two test cases but it is giving a run time error for rest of the test cases.
Intersection Of two Linked Lists
https://ide.codingblocks.com/s/253896 Corrected code.
Errors:
- Use
while (d++ < 0) {in case d2>d1. In your code there was an error in that. - Put
while(c1 != null && c2 != null)use this condition while checking for c1.data==c2.data. Because in case c1 or c2 end up being null, your code will give an error (null pointer exception).