C++/题解:
先从头到尾遍历,后翻转;
C++/代码:

class Solution {
public:
    vector<int> printListFromTailToHead(ListNode* head) {
        vector<int> res;
        while (head) {
            res.push_back(head->val);
            head = head->next;
        }
        return vector<int> (res.rbegin(),res.rend());
    }
};