题解 | #反转链表#
反转链表
http://www.nowcoder.com/practice/75e878df47f24fdc9dc3e400ec6058ca
typedef struct ListNode Node;
struct ListNode* ReverseList(struct ListNode* pHead ) {
int i;
Node* pPre = NULL;
Node* pStart = pHead;
Node* pTemp = NULL;
if(!pHead||!(pHead->next))
return pHead;
while(pStart->next!=NULL)
{
pTemp = pStart->next;
pStart->next=pPre;
pPre = pStart;
pStart=pTemp;
}
pStart->next = pPre;
return pStart;
}