Reverse a Linked list
Anonymous
//function in C++ Node *reverse(Node *head){ /*Assuming struct Node{ int info; Node *next; }; */ Node *prev=NULL,*next=NULL; while(head!=NULL){ next=head->next; head->next=prev; prev=head; head=next; } return prev; }
Check out your Company Bowl for anonymous work chats.