/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode() {}
* ListNode(int val) { this.val = val; }
* ListNode(int val, ListNode next) { this.val = val; this.next = next; }
* }
*/
class Solution {
public int[] reverseBookList(ListNode head) {
ListNode p=head;
List<Integer> list=new ArrayList<>();
while(p!=null){
list.add(p.val);
p=p.next;
}
int n=list.size();
int[] arr=new int[n];
for(int i=0;i<n;i++){
arr[i]=list.get(n-1-i);
}
return arr;
}
}
LCR 123. 图书整理 I
最新推荐文章于 2024-11-04 19:24:37 发布