Intersection point of 2 ll

error

  while(fast!=NULL&&fast->next!=NULL){
        fast = fast->next;
        slow = slow->next;
        if(fast == slow){
            return slow;
        }
 

instead of this

do

while (slow != NULL && fast != NULL)
    {
        if (slow != fast)
        {
            slow = slow->next;
            fast = fast->next;
            continue;
        }
        return slow;
    }
    return NULL;

https://ide.codingblocks.com/s/277841

it is still giving error
int len(Node head){
Node
temp = head;
int count = 0;
while (temp!=NULL){
count++;
temp = temp->next;
}
return count;
}
Node *intersectionOfTwoLinkedLists(Node *l1, Node *l2)
{
/Code here/
int len1 = len(l1);
int len2 = len(l2);
Node *fast;
Node *slow;
int d;
if(len1>len2){
d = len1-len2;
fast = l1;
slow = l2;
for(int i=0;i<d;i++){
fast = fast->next;
}
}
else{
d = len2-len1;
fast = l2;
slow = l1;
for(int i=0;i<d;i++){
fast = fast->next;
}
}

while (slow != NULL && fast != NULL)
{
if (slow != fast)
{
slow = slow->next;
fast = fast->next;
continue;
}
return slow;
}
return NULL;
}

please share code in cb ide
hard to debugthis way

@ayu2321
what is the problem that u are facing??

TLE is coming in that code

hey
ur code is correct


i guess u just ran the sample input but read the thing in parenthesis

if u submit ur code it gives correct answer 100%