Node* ReverseLinkedList(Node* root)
{
if(!root)
return NULL;
Node* pre = root;
Node* next = root->next;
root->next = NULL;
while(root->next)
{
root = next
next = root->next;
root->next = pre;
pre = root;
}
return root;
}
No comments:
Post a Comment