Intersection Of two Linked Lists

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.

@ap8730390,

https://ide.codingblocks.com/s/253896 Corrected code.

Errors:

  1. Use while (d++ < 0) { in case d2>d1. In your code there was an error in that.
  2. 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).