/**
 * struct ListNode {
 *	int val;
 *	struct ListNode *next;
 * };
 */

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