标签:node sel 示例 keyword list ever null nod 一个
反转一个单链表。
示例:
输入: 1->2->3->4->5->NULL
输出: 5->4->3->2->1->NULL
struct ListNode* reverseList(struct ListNode* head){
struct ListNode *pre = NULL;
struct ListNode *curr = head;
while(curr)
{
struct ListNode *next = curr->next;
curr->next = pre;
pre = curr;
curr = next;
}
return pre;
}
标签:node sel 示例 keyword list ever null nod 一个
原文地址:https://www.cnblogs.com/one-think/p/12492545.html