/*
* Definition for singly-linked list.
* class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
/
class Solution {
public int[] printListReversingly(ListNode head) {
if(head==null)return null;
int count=1;
ListNode point=head;
while(point.next!=null){
count++;
point=point.next;
}
int[] arr=new int[count];
for(int i=count-1;i>=0;i–){
arr[i]=head.val;
head=head.next;
}
return arr;
}
}