struct ListNode {
int val;
struct ListNode *next;
};
struct ListNode* reverseList(struct ListNode* head) {
struct ListNode* pNode = head;
struct ListNode* PreNode = NULL;
struct ListNode* NewHead = NULL;
while(pNode != NULL)
{
struct ListNode* pNext = pNode->next;
if(pNext == NULL)
{
NewHead = pNode;
}
pNode->next = PreNode;
PreNode = pNode;
pNode = pNext;
}
return NewHead;
}