/*
struct ListNode {
int val;
struct ListNode *next;
ListNode(int x) :
val(x), next(NULL) {
}
};*/
class Solution {
public:
ListNode* ReverseList(ListNode* pHead) {
ListNode *prev=NULL;
while(pHead!=NULL){
ListNode *curr=pHead;
pHead=pHead->next;
curr->next=prev;
prev=curr;
}
return prev;
}
};

京公网安备 11010502036488号