【leetcode】从尾到头打印链表

//利用循环一直到空指针然后申请数组通过递归一层层赋值并返回
int
* reversePrint(struct ListNode* head, int* returnSize){ if(head == NULL){ *returnSize = 0; return malloc(sizeof(int) * 10000); } int *ans = reversePrint(head->next, returnSize); ans[(*returnSize)++] = head->val; return ans; }
原文地址:https://www.cnblogs.com/ganxiang/p/13546726.html