leetcode 206 翻转链表
输入: 2->3->4->5->NULL
输出: 5->4->3->2->NULL
class Solution {
public:
ListNode* reverseList(ListNode* head) {
ListNode *next=NULL;
ListNode *pre=NULL;
while(head!=NULL)
{
next=head->next;
head->next=pre;
pre=head;
head=next;
}
return pre;
}
};