struct ListNode* ReverseList(struct ListNode* pHead ) {
// write code here
struct ListNode* tmp = ( struct ListNode*)malloc(sizeof(struct ListNode));
tmp->next = NULL;
//空列表头节点
struct ListNode* n = ( struct ListNode*)malloc(sizeof(struct ListNode));
//n来暂存下一个,当pHead是空的时候就不插入
for ( n = pHead->next; pHead != NULL; n = pHead->next) {
pHead->next = tmp->next;
tmp->next = pHead;
pHead = n;
}
return tmp->next;
}