思路1:取节点头插,并保存下一个节点
思路2:1->NULL,2->1, 3->2, 4->3,5->4
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode* reverseList(struct ListNode* head){
struct ListNode* phead = NULL;
struct ListNode* cur = head;
while(cur)
{
struct ListNode* next = cur->next;
cur->next = phead;
phead = cur;
cur = next;
}
return phead;
}