java实现删除链表的中间节点

互联网 20-10-23

目的:

(推荐教程: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实现删除链表的中间节点的详细内容,更多内容请关注技术你好其它相关文章!

来源链接:
免责声明:
1.资讯内容不构成投资建议,投资者应独立决策并自行承担风险
2.本文版权归属原作所有,仅代表作者本人观点,不代表本站的观点或立场
标签: 中间节点
上一篇:php获取远程图片并下载保存到本地的方法分析 下一篇:java怎么获取当前日期

相关资讯