思路:经过我的归纳,链表每增加2,要删除的节点就向后移动一个
public class Node {
public int vaule;
public Node next;
public Node(int data){
vaule=data;
}
}
public static Node removeMidNode(Node head){
if(head==null||head.next==null){
return head;
}
if(head.next.next==null){
return head.next;
}
Node pre=head;
Node cur=head.next.next;
while (cur.next!=null&&cur.next.next!=null){
pre=pre.next;
cur=cur.next.next;
}
pre.next=pre.next.next;
return head;
}