Precise Solution


#1

typedef ListNode* lptr; void recursive(lptr &head,lptr &h) { if(h==NULL) return; if(h->next!=NULL) recursive(head,h->next); if(head==NULL) { head=h; return; } else { lptr temp=head; while(temp->next!=NULL) temp=temp->next; h->next=NULL; temp->next=h; return; } } ListNode* Solution::reverseList(ListNode* A) { if(A==NULL) return NULL; else { lptr head=NULL; recursive(head,A); return head; } }