Why i got wrong answer?

int intersectPoint(Node* head1, Node* head2)
{
Nodep= head1;
Node
q = head2;

    int c1=0,c2=0,cdiff=0; //c == count
    
    while(p!=NULL) //length of 1st linked list
    {  c1++;
       p=p->next;
    }
    
    while(c2!=NULL) //length of 2nd linked list
    { c2++;
      q=q->next;
    }
    
cdiff=max(c1,c2)-min(c1,c2);  //diff in number of nodes

p=head1;
q=head2;
if(c1>c2) {
for (int i=0;i<cdiff;i++){ // to make the pointers ponit at equal distance from the common node
if (p == NULL)
return -1;

        p=p->next;}
   }


if(c2>c1){  
    for (int i=0;i<cdiff;i++){
        if (q == NULL)       // null before common node , i.e common node not exixt
               return -1;
        
        q=q->next;}
   }

    while(p!=NULL && q!=NULL){
        if(p==q)     //compare the nodes instead of the data
            return p->data;
        
        p=p->next;
        q=q->next;
        
    }
    
   return -1;

// Your Code Here

}

https://discuss.codechef.com/t/a-few-tips-to-get-faster-response-for-your-problem/60990/2

kindly post the link to your question and your code
also give an overview as to what your code is doing

my code is returning NULL instead of intersected NODE …follow the above link pls …

sry but i dont know how linked list work …
:sweat_smile:

and reading your code is quite hard as its not formated properly…
just paste your code in an online IDE (like https://ideone.com/) and post a link instead of the whole code