题目来源:
leetcode题目,网址:LCR 123. 图书整理 I - 力扣(LeetCode)
解题思路:
遍历链表获得图书的正序,然后倒序遍历即可。
解题代码:
/**
* 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) {
List<Integer> list=new ArrayList<>();
while(head!=n