Intersection point two linked lists

two testcases giving runerror

Hello @ayush1213,

Reason for TLE:
Consider the following test cases:

  1. When the length of both linked list is equal.
    4
    20 30 40 50
    4
    20 30 40 50
    Expected Output:
    20

  2. When the length of the second linked list is greater i.e. l2>l1.
    4
    20 30 40 50
    5
    10 20 30 40 50
    Expected Output:
    20
    Correct the above-mentioned problems in your code.

Hint: What is t in the else condition? zero?
Solution: t=-l;

Reason for the run error:
You have not handled the case when they do not meet:
1
0
2
5 10
Output:
-1

Reason for no output:

  1. Output should be 0.
    1
    0
    1
    0
  2. When they meet at the last element:
    10
    1 2 3 4 5 6 7 8 9 10
    3
    12 11 10

Modify your code.

Hope, this would help.
Give a like, if you are satisfied.

1 Like

@S18ML0016 https://ide.codingblocks.com/s/135959
but now it is giving untime error i mm unable to firgure it out

@S18ML0016 GOT IT SIR TQ

Please, mark it as resolved.:blush:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.