题解:#从尾到头打印链表#
/**
* struct ListNode {
* int val;
* struct ListNode *next;
* ListNode(int x) :
* val(x), next(NULL) {
* }
* };
*/
#include <vector>
class Solution {
public:
vector<int> printListFromTailToHead(ListNode* head) {
vector<int> v;
if(head)
{
v=printListFromTailToHead(head->next);
v.push_back(head->val);
}
return v;
}
};
#剑指offer#剑指offer刷题 文章被收录于专栏
坚持!努力!学习
