There are some errors about my code..but I can run it via vs2008


  • 0
    R
    ListNode* removeNthFromEnd(ListNode head,int n){
    int count=0;
    ListNode *p,*q,*previous;
    previous=head;
    p=head->next;
    q=head->next;
    if(p == NULL||p->Next==NULL)
           return NULL;
    while(count<n){
    	p=p->next;
    	count++;
    }
    while(p){
    	p=p->next;
    	previous=q;
    	q=q->next;
    }
    previous->next=q->next;
    free(q);
    return head;}

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.