ListNode* ReverseList(ListNode* pHead)
{
if (pHead == NULL)
{
return NULL;
}
ListNode pHeadNew(0);
pHeadNew.next = pHead;
ListNode* curNode = pHead;
ListNode* nextNode = pHead->next;
while (nextNode != NULL)
{
curNode->next = nextNode->next;
nextNode->next = pHeadNew.next;
pHeadNew.next = nextNode;
nextNode = curNode->next;
}
return pHeadNew.next;
}