题目描述
blablabla
样例
blablabla
C++ 代码
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
vector<int> res;
public:
vector<int> printListReversingly(ListNode* head) {
if(head==NULL){
return res;
}
find(head);
return res;
}
void find(ListNode* head){
if(head->next!=NULL){
find(head->next);
}
res.push_back(head->val);
}
};