/**
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
/**
*
* @param pHead ListNode类
* @return ListNode类
*/
struct ListNode* ReverseList(struct ListNode* pHead ) {
// write code here
struct ListNode *p=pHead;
struct ListNode *q,*r;
if(p!=NULL){
r=p->next;
p->next=NULL;
while(r!=NULL){
q=r->next;
r->next=p;
p=r;
r=q;
}
}
return p;
} 

京公网安备 11010502036488号