/**
* 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) {
ListNode *cur = head;
ListNode *pre = nullptr;
ListNode *aux = nullptr;
while (cur != nullptr) {
aux = cur->next;
cur->next = pre;
pre = cur;
cur = aux;
}
return pre;
}
};
10-09
245
10-13
771
10-14
1192