class Solution {
public int[] printListReversingly(ListNode head) {
ListNode t = head;
int n = 0;
while(t!=null){
n++;
t =t.next;
}
int[] result = new int[n];
t = head;
while(t!=null){
result[--n] = t.val;
t = t.next;
}
return result;
}
}