[容易]在O(1)时间复杂度删除链表节点
题目来源:http://www.lintcode.com/zh-cn/problem/delete-node-in-the-middle-of-singly-linked-list/
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAA4wAAAF+CAIAAABGbQPOAAAgAElEQVR4nO3d347bVp4n8H2ZfoJ9jum9Gvhiex9gsNOLFRAY6Is8QKyrdBlYLAazi7KQBTo38UUvEkNAgFz0tFEXKUA9QSYIehxjXY7amXE60xM7rnJZeyFSPCQPyUOWVKJcnw9+SGyJ/w5JUV8d/vF/WAEAwMj8h30vAAAAVAmpAACMjpAKu/If/+e+lwAADpaQCrsipALAYEIq7IqQCgCDCamwK0IqAAx2hZB6dv/2raOToWMvZpPJZLYYPvtrt5xPJ9P5svpa9aUeUxu8AmKLkm4xm1xh7CHLsZxPm2cZLs5yPq2slPSFXczS12dkwfuOnjKwkAoAgw0PqSdHt27dunX7/tmgsQ8vo8ZD6mI2neQpap07m5RGbR+0ebyWRenZkra1v5gVs58tyktba0b2QqVF4WCbt6JzLLelGv96tFRIBYC3ydCQenb/9q3bR0e3byV2poa5J1E5BFQn0Bh4qu8sZrWkV+2dqy9cbOqNeWk5n3YklsqoA7oyU1JtbBn6rfdsoRaz9Z/yhm0aGL4xnS+rIbUYPViWfJs0BLvqWi0N3rCEfXem2WLQDti8Udu2RjiSkAoAgw0MqSdH63R6cjSkM7VnN+o6EkR6IitBrx6DNmGiGgnLMbGcqpq61GJxKjFqVnscp9OkjtSmqffoB+zTPxiOdIWQGs6yvEki4bwc9yrTTIj/A5uqJxUAxm5QSD27fzuPpmf3kztTc/ULFFvjXmOirb5RiUBZ/JktolMvxYxYSG3vecujW9+Qms+pOxG1TD3WEVuaYPCX0uup0exKITUfZlX6Y7AE1Y1UnX3RvGyaifFRSAWAt0lqSF1fgVoocmnzO3GR0NkSyNpuuSm/V4tui1kp6sRGjiW5QT2pbSenY4uQdvI51u7I1Qu1ha6G1Fnqqe5ipMEhtTRIc4fxek71FBtb4ZEN0ufkfeKlG20h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elvxrObhQsDAOxXUki9fPP6d09/83d/+Ju9Zxr11tTf/eFvfvf0N5dvXo9hN6svDACwX0khFQAArpOQCgDA6AipAACMjpAKAMDoCKkAAIyOkAoAwOgIqQAAjI6QCgDA6AipAACMjpAKAMDo/H+yxzR/yVDq4QAAAABJRU5ErkJggg==" alt="" />
这题主要是题意一开始不明白,举个例子:
8->6->3->1->9->2->null, 1
输出
8->6->3->9->2->null
传入的是要删除节点的地址。
方法是,将删除节点下个节点的值赋给本节点,再将下一节点删除。
题目说删除的不能是表头和表尾,但是数据测试了一下,只是不能是表尾。
8->6->3->1->9->2->null, 2
输出
8->6->3->1->9->2->null
/**
* Definition of ListNode
* class ListNode {
* public:
* int val;
* ListNode *next;
* ListNode(int val) {
* this->val = val;
* this->next = NULL;
* }
* }
*/
class Solution {
public:
/**
* @param node: a node in the list should be deleted
* @return: nothing
*/
void deleteNode(ListNode *node) {//把下个节点的值赋值给本节点,把下个节点删除,相当于删除了本节点
// write your code here
if(node==NULL||node->next==NULL) return;
ListNode *next=node->next;
node->val=next->val;
node->next=next->next;
return;
}
};
[容易]在O(1)时间复杂度删除链表节点的更多相关文章
- lintcode:在O(1)时间复杂度删除链表节点
题目: 在O(1)时间复杂度删除链表节点 给定一个单链表中的表头和一个等待被删除的节点(非表头或表尾).请在在O(1)时间复杂度删除该链表节点.并在删除该节点后,返回表头. 样例 给定 1->2 ...
- LintCode-372.在O(1)时间复杂度删除链表节点
在O(1)时间复杂度删除链表节点 给定一个单链表中的一个等待被删除的节点(非表头或表尾).请在在O(1)时间复杂度删除该链表节点. 样例 给定 1->2->3->4,和节点 3,删除 ...
- 基于visual Studio2013解决面试题之0604O(1)时间复杂度删除链表节点
题目
- lintcode 在O(1)时间复杂度删除链表节点
题目要求 给定一个单链表中的一个等待被删除的节点(非表头或表尾).请在在O(1)时间复杂度删除该链表节点. 样例 Linked list is 1->2->3->4, and giv ...
- 在O(1)时间复杂度删除链表节点
题目描述: 给定一个单链表中的一个等待被删除的节点(非表头或表尾).请在在O(1)时间复杂度删除该链表节点. 您在真实的面试中是否遇到过这个题? Yes 样例 给定 1->2->3-> ...
- 372 在O(1)时间复杂度删除链表节点
原题网址:http://www.lintcode.com/zh-cn/problem/delete-node-in-the-middle-of-singly-linked-list/ 给定一个单链表中 ...
- LintCode_372 在O(1)时间复杂度删除链表节点
题目 给定一个单链表中的表头和一个等待被删除的节点(非表头或表尾).请在在O(1)时间复杂度删除该链表节点.并在删除该节点后,返回表头. 思路 因为O(1)内删除所以 不能从头节点去遍历找他的前驱节点 ...
- Lintcode 372. O(1)时间复杂度删除链表节点
----------------------------------- AC代码: /** * Definition for ListNode. * public class ListNode { * ...
- 剑指offer编程题Java实现——面试题13在O(1)时间内删除链表节点
题目:给定单向链表的头指针和一个节点指针,定义一个函数在O(1)时间删除该节点. 由于给定的是单向链表,正常删除链表的时间复杂度是查找链表的时间复杂度即O(n),如果要求在O(1)时间复杂度内删除节点 ...
随机推荐
- 【spring boot logback】日志使用自定义的logback-spring.xml文件后,application.properties中关于日志的相关配置还会起作用么
本篇 将针对[日志使用自定义的logback-spring.xml文件后,application.properties中关于日志的相关配置还会起作用么]这一个主题进行探索. 这个测试项目是根据[spr ...
- D-Link service.cgi远程命令执行漏洞复现
1.1 概述 友讯集团(D-Link),成立于1986年,1994年10月于台湾证券交易所挂牌上市,为台湾第一家上市的网络公司,以自创D-Link品牌行销全球,产品遍及100多个国家. 1月17日,C ...
- mock平台架构及实现
转载: http://blog.csdn.net/xkhgnc_6666/article/details/51757209 在测试过程中有些情况通过手工测试是无法测试出来的或是非常难复现,比如网络异常 ...
- 对国外某hotel的内网域简单渗透
Penetration Testing不单单是一个博客,更热衷于技术分享的平台. 本文将讲述对国外某一hotel的渗透测试,让更多的人安全意识得到提高,有攻才有防,防得在好,也有疏忽的地方,这就是为啥 ...
- es6 - foreach
foreach ... // es5 - foreach arr.forEach(function(value, index, arr) { console.log(value, index, arr ...
- js:|| 和 && 运算符 特殊用法
引用:http://www.jb51.net/article/21339.htm 先总结一下: 几乎所有语言中||和&&都遵循“短路”原理,如&&中第一个表达式为假就不 ...
- Android MarginLeft与MarginStart的差别
在写layout布局的时候,我们会发现有这样几个比較相似的属性: MarginStart MarginLeft MarginEnd MarginRight 这些属性的差别是什么? 依据ap ...
- Hadoop--设置单一节点集群
目的 这篇文档描述如何安装和配置一个单一节点的Hadoop,以便你可以快速使用hadoop mapreduce和Hadoop Distributed File System (HDFS)的一些简单操作 ...
- PX4学习之-uORB简单体验
一.前言 最近项目使用到 CPU2 与 CPU0 之间的通信, 使用定时器传递消息到 CPU0 后, CPU0 需要将消息分发到不同的应用程序里面. PX4 里面使用的是 uORB 多线程/进程通信机 ...
- Java方法存在于哪一区
Java运行时的数据区包括:(其中前两个是线程共享的) 1.方法区(Method Area)存储已被虚拟机加载的类信息.常量.静态变量.即编译器编译后的代码等数据 2.堆(Heap)存放对象实例,几乎 ...