/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* reverseList(ListNode* head) {
if(head == NULL)
return NULL;
ListNode * t = head;
head = head->next;
t->next = NULL;
ListNode* tNext = t;
while(head != NULL)
{
t = head;
head = head->next;
t->next = tNext;
tNext = t;
}
return t;
}
};
LeetCode || Submission Details
最新推荐文章于 2018-04-14 10:52:16 发布