struct ListNode* ReverseList(struct ListNode* pHead ) { struct ListNode *p1,*p2,*p3; if(pHead!=NULL) { p1=pHead; while(p1!=NULL) { p2=(struct ListNode *)malloc(sizeof(struct ListNode)); p2->val=p1->val; p2->next=p3; p3=p2; p1=p1->next; if(p1==NULL) break; } return p3; } else return pHead; // write code here }