输入一个链表,按链表值从尾到头的顺序返回一个ArrayList。
vector<int> iVec;
vector<int> printListFromTailToHead(ListNode* head) {
if(head == NULL)
return iVec;
if(head != NULL){
if(head->next != NULL)
printListFromTailToHead(head->next);
iVec.push_back(head->val);
}
return iVec;
}