class Solution {
public int[] printListReversingly(ListNode head) {
int count = 0;
ListNode temp = head;
while(temp!=null){
temp = temp.next;
count++;
}
int [] reverseArray = new int [count];
for (int i = count-1 ; i >= 0 ; i-- ){
if(head != null)
reverseArray[i] = head.val;
head = head.next;
}
return reverseArray;
}
}