标签:public com 面试 efi leetcode array color turn eve
题目描述:
java
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ class Solution { public int[] reversePrint(ListNode head) { Stack<Integer> stack = new Stack<>(); while(head != null){ stack.push(head.val); head = head.next; } int size = stack.size(); int [] array = new int[size]; for(int i = 0; i < size; i++){ array[i] = stack.pop(); } return array; } }
标签:public com 面试 efi leetcode array color turn eve
原文地址:https://www.cnblogs.com/oldby/p/12621003.html