* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
/**
* Note: The returned array must be malloced, assume caller calls free().
*/
int* reversePrint(struct ListNode* head, int* returnSize){
int total=0;
struct ListNode*p=head;
int *res=malloc(10000*sizeof(int));
memset(res,0,10000*sizeof(int));
while(p)
{
res[total++]=p->val;
p=p->next;
}
for (int i=0;i<total/2;i++)
{
int tmp=res[i];
res[i]=res[total-i-1];
res[total-i-1]=tmp;
}
(*returnSize)=total;
return res;
}