从尾到头打印链表 Posted on 2020-02-08 题目描述 输入一个链表,按链表从尾到头的顺序返回一个ArrayList。 12345678910111213141516public ArrayList<Integer> printListFromTailToHead(ListNode listNode) { Stack<Integer> mIntegerStack = new Stack<>(); while (listNode != null) { mIntegerStack.push(listNode.val); listNode = listNode.next; } ArrayList<Integer> mList = new ArrayList<>(); for (; !mIntegerStack.isEmpty(); ) { mList.add(mIntegerStack.pop()); } return mList;}