/** * Definition for ListNode * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * } */publicclassSolution { /** * @param head: the given linked list * @return: the array that store the values in reverse order */publicList<Integer> reverseStore(ListNode head) {List<Integer> arr =newArrayList<Integer>();storeHelper(head, arr);return arr; }privatevoidstoreHelper(ListNode head,List<Integer> arr) {if (head ==null) return;storeHelper(head.next, arr);arr.add(head.val); }}