
目的:
删除链表的中间节点
(推荐教程:java课程)
代码实现:
立即学习“Java免费学习笔记(深入)”;
public class Node{
public int value;
public Node next;
public Node(int data){
this.value=data;
}
}
public 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;
}相关推荐:java入门
以上就是java实现删除链表的中间节点的详细内容,更多请关注php中文网其它相关文章!
java怎么学习?java怎么入门?java在哪学?java怎么学才快?不用担心,这里为大家提供了java速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号