class Solution {
public:
ListNode* ReverseList(ListNode* pHead) {
ListNode* prev = nullptr;
ListNode* curr = pHead;
while ( curr != nullptr ){
curr = pHead->next;
pHead->next = prev;
prev = pHead;
pHead = curr;
}
return prev;
}
};
原文:https://www.cnblogs.com/theodoric008/p/9535024.html