/**
* @author chencc
* @Description 双向链表
* @Date 2022/3/3 16:43
*/
public class DoubleListReverse {
public static class DoubleNode {
public int value;
public DoubleNode next;
public DoubleNode last;
}
public static DoubleNode reverseList(DoubleNode head) {
DoubleNode pre = null;
DoubleNode next = null;
while (head != null) {
//记录下head下一个节点位置
next = head.next;
head.next = pre;
head.last = next;
pre = head;
head = next;
}
return pre;
}
}
双向链表反转
于 2022-03-03 17:45:43 首次发布