/**
* struct ListNode {
* int val;
* struct ListNode *next;
* ListNode(int x) :
* val(x), next(NULL) {
* }
* };
*/
class Solution {
public:
vector<int> printListFromTailToHead(ListNode* head)
{
vector<int >result ;
stack<int>st;
if(head==nullptr)
return result;
ListNode *p=head;
while(p)
{
st.push(p->val);
p=p->next;
}
while(st.size())
{
int temp=st.top();
result.push_back(temp);
st.pop();
}
return result;
}
};