无脑递归,并没有什么骚方法,有点儿费内存就是
class Solution {
public:
vector<int> printListReversingly(ListNode* head) {
vector<int> r;
if(head == NULL)return r;
fun(head,r);
return r;
}
void fun(ListNode* Next,vector<int>& arr){
if(Next -> next != NULL){
fun(Next -> next,arr);
}
arr.push_back(Next -> val);
}
};