用时12分钟
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
vector<int> reversePrint(ListNode* head) {
vector<int> a;
while(head){
a.push_back(head->val);
head = head->next;
}
vector<int> b;
for (int i = a.size() - 1; i >= 0; i--){
b.push_back(a[i]);
}
return b;
}
};