public static void printListReverse(ListNode head) {
        if (head == null) {
            return;
        }

        Stack<ListNode> stack = new Stack<ListNode>();
        while (head != null) {
            stack.add(head);
            head = head.next;
        }
        while (!stack.isEmpty()) {
            System.out.println(stack.pop().val);
        }
    }