// 反转单链表public static Node ReverseList(Node head) {Node next = null ; // 保留节点后驱Node pre = null; // 保留节点前驱while(head != null){next = head.next;head.next = pre;pre = head;head = next;}return pre;}// 翻转双链表public static DoubleNode reverseDoubleList(DoubleNode head) {DoubleNode pre = null;DoubleNode next = null;while (head != null) {next = head.next;head.next = pre;head.last = next;pre = head;head = next;}return pre;}
