链接:
题意:
如题
解:
递归OR翻转
实际代码:
c++
#include<bits/stdc++.h>
using namespace std;
struct ListNode
{
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
vector<int> reversePrint(ListNode* head)
{
vector<int>ans;
auto bi=inserter(ans,ans.begin());
while(head!=nullptr)
{
bi=head->val;
head=head->next;
}
reverse(ans.begin(),ans.end());
return ans;
}
int main()
{
}
限制:
0 <= 链表长度 <= 10000