/* struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { } };*/ class Solution { public: ListNode* ReverseList(ListNode* pHead) { ListNode* nHead = nullptr; while (pHead != nullptr) //每次在新链表的首部插入原链表的首结点 { ListNode* temp = nHead; nHead = pHead; pHead = pHead->next; nHead->next = temp; } return nHead; } };