问题描述
解题思路
实现源码
/**
* struct ListNode {
* int val;
* struct ListNode *next;
* ListNode(int x) :
* val(x), next(NULL) {
* }
* };
*/
class Solution {
public:
vector<int> printListFromTailToHead(ListNode* head) {
vector<int> temp,result;
struct ListNode *node = head;
while(node != NULL) {
temp.push_back(node->val);
node = node->next;
}
reverse(temp.begin(),temp.end());
return temp;
}
};