Reverse a singly linked list.
思路:没啥好说的。秒...
ListNode* reverseList(ListNode* head) {
ListNode * rList = NULL, * tmp = NULL;
while(head != NULL)
{
tmp = rList;
rList = head;
head = head->next;
rList->next = tmp;
}
return rList;
}
Reverse a singly linked list.
思路:没啥好说的。秒...
ListNode* reverseList(ListNode* head) {
ListNode * rList = NULL, * tmp = NULL;
while(head != NULL)
{
tmp = rList;
rList = head;
head = head->next;
rList->next = tmp;
}
return rList;
}