/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
vector<int> reversePrint(ListNode* head) {
if(!head)
{
return {};
}
vector<int> v;
while(head)
{
v.push_back(head->val);
head = head->next;
}
reverse(v.begin(), v.end());
return v;
}
};
leetcode 剑指 Offer 06. 从尾到头打印链表
猜你喜欢
转载自blog.csdn.net/weixin_43956456/article/details/107721128
今日推荐
周排行