Enter a list, by returning a list sequentially from the tail to the head of ArrayList.
Easily implemented stack, the stack structure is recursive nature, can be implemented by recursion,
vector<int> printListFromTailToHead(ListNode* head) {
ListNode* iter = head;
stack<int> nums;
vector<int> result;
while(iter != NULL){
nums.push(iter->val);
iter = iter->next;
}
while(!nums.empty()){
result.push_back(nums.top());
nums.pop();
}
return result;
}