struct ListNode* ReverseList(struct ListNode* pHead ) {
    // write code here
    if(!pHead)
        return pHead;
    struct ListNode *p,*x;
    struct ListNode *head;
    head=(struct ListNode*)malloc(sizeof(struct ListNode));
    head->next=NULL;
    p=pHead;
    while(p)
    {
        x = (struct ListNode*)malloc(sizeof(struct ListNode));
        x->val=p->val;
        x->next=head->next;
        head->next=x;
        p=p->next;
    }
    return head->next;
}