206. 反转链表 - 力扣(LeetCode)
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode* reverseList(struct ListNode* head)
{
if (NULL == head)
return head;
struct ListNode* a = NULL;
struct ListNode* b = head;
struct ListNode* c = head->next;
while (c)
{
b->next = a;
a = b;
b = c;
c = c->next;
}
b->next = a;
return b;
}