/**
* struct ListNode {
* int val;
* struct ListNode *next;
* ListNode(int x) :
* val(x), next(NULL) {
* }
* };
*/
class Solution {
public:
vector<int> printListFromTailToHead(ListNode* head) {
vector<int> v;
while(head!=NULL){
v.push_back(head->val);
head = head->next;
}
vector<int> v2;
for(int i=v.size()-1; i>=0; i--){
v2.push_back(v[i]);
}
return v2;
}
};
* struct ListNode {
* int val;
* struct ListNode *next;
* ListNode(int x) :
* val(x), next(NULL) {
* }
* };
*/
class Solution {
public:
vector<int> printListFromTailToHead(ListNode* head) {
vector<int> v;
while(head!=NULL){
v.push_back(head->val);
head = head->next;
}
vector<int> v2;
for(int i=v.size()-1; i>=0; i--){
v2.push_back(v[i]);
}
return v2;
}
};