/** * struct ListNode { * int val; * struct ListNode *next; * ListNode(int x) : * val(x), next(NULL) { * } * }; */ class Solution { public: vector<int> printListFromTailToHead(ListNode* head) { vector<int> vec; if(head != NULL) { if(head->next != NULL) { vec = printListFromTailToHead(head->next); } vec.push_back(head->val); } return vec; } };
原文:https://www.cnblogs.com/evidd/p/10615813.html