struct ListNode* reverseList(struct ListNode* head){
struct ListNode*p=head;
if(head==NULL)
{
return head;
}
int len=0;
while(p!=NULL)
{
len++;
p=p->next;
}
int list[len];
p=head;
int i=0;
while(p!=NULL)
{
list[i]=p->val;
i++;
p=p->next;
}
i=len-1;
p=head;
while(p!=NULL)
{
p->val=list[i];
i--;
p=p->next;
}
return head;
}