博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[LeetCode]:237:Delete Node in a Linked List
阅读量:7060 次
发布时间:2019-06-28

本文共 543 字,大约阅读时间需要 1 分钟。

题目:

Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.
Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value 3, the linked list should become 1 -> 2 -> 4 after calling your function.

 

重点解析:

 

代码:

public static void deleteNode(ListNode node) {        if(node.next == null){            return;        }        node.val = node.next.val;        node.next = node.next.next;      }

时间消耗:Runtime: 352 ms

转载于:https://www.cnblogs.com/savageclc26/p/4775148.html

你可能感兴趣的文章
安装SP3后不能进入系统的办法
查看>>
20150905日课程作业(计划任务mail,at,cron,)
查看>>
shell训练营Day15
查看>>
MySQL常用语句命令
查看>>
关于字符串的一些操作
查看>>
bootstrap-导航(垂直堆叠带分隔线的导航)
查看>>
安装tomcat-7.0.61图文
查看>>
游戏程序员的学习指南(必看)(二)
查看>>
手把手教你如何建立自己的Linux系统(LFS速成手册)
查看>>
初识 sqlite 与 content provider 学习笔记
查看>>
java--ftp的断点上传和断点下载
查看>>
11.SSH整合
查看>>
PowerShell记录脚本运行过程
查看>>
OpenSUSE下启动ssh和samba服务以及防火墙设置
查看>>
linux nethogs查看进程流量
查看>>
pip 安装报utf-8错解决办法
查看>>
django 中form在html中的简单使用
查看>>
lync 2013标准版安装
查看>>
WebService基础介绍
查看>>
jdbc的使用
查看>>