/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode* reverseList(struct ListNode* head){
struct ListNode *phead = NULL;
struct ListNode *pcur = head;
struct ListNode *pnext = NULL;
phead = (struct ListNode *)malloc(sizeof(struct ListNode));
memset(phead, 0, sizeof(struct ListNode));
while (pcur != NULL) {
pnext = pcur->next;
pcur->next = phead->next;
phead->next = pcur;
pcur = pnext;
}
return phead->next;
}