从头到尾打印,然后逆序 或者利用栈的先进后出
vector<int> printListFromTailToHead(ListNode* head) {
vector<int> res;
while(head){
res.push_back(head->val);
head = head->next;
}
reverse(res.begin(), res.end());
return res;
}