剑指offer 反转链表
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;
}
};