C++/题解/代码:
从尾到头打印链表
http://www.nowcoder.com/questionTerminal/d0267f7f55b3412ba93bd35cfa8e8035
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());
}
};
汤臣倍健公司氛围 399人发布

