vector<int> printListFromTailToHead(ListNode* head) { vector<int> res; if(!head) return res; ListNode *p = head; while(p) { res.push_back(p->val); p = p->next; } reverse(res.begin(),res.end()); return res; }
vector<int> printListFromTailToHead(ListNode* head) { vector<int> res; if(!head) return res; ListNode *p = head; while(p) { res.push_back(p->val); p = p->next; } reverse(res.begin(),res.end()); return res; }
转载于:https://www.cnblogs.com/xiuxiu55/p/6477163.html