代码:输入一个链表的头节点,从尾到头反过来返回每个节点的值(用数组返回)。
class Solution {
public int[] reversePrint(ListNode head) {
//第一反应用一个栈存
ArrayList list = new ArrayList();
if(head==null)
return new int[0];
while(head!=null){
list.add(0,head.val);
head=head.next;
}
int len = list.size();
int[] res = new int[len];
for(int i=0;i 


