开始没看懂题目的意思,以为是输入一个单链表,删掉链表中间的那个节点。

实际的意思是,传入的参数就是待删节点,所以只要把当前节点指向下一个节点就可以了。

C++

 /**
* 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
node->val = node->next->val;
node->next = node->next->next;
}
};

LintCode: Delete Node in the Middle of Singly Linked List的更多相关文章

  1. [LintCode] Delete Node in the Middle of Singly Linked List 在单链表的中间删除节点

    Implement an algorithm to delete a node in the middle of a singly linked list, given only access to ...

  2. 372. Delete Node in a Linked List【LintCode java】

    Description Implement an algorithm to delete a node in the middle of a singly linked list, given onl ...

  3. [CareerCup] 2.3 Delete Node in a Linked List 删除链表的节点

    2.3 Implement an algorithm to delete a node in the middle of a singly linked list, given only access ...

  4. [LeetCode] Delete Node in a Linked List 删除链表的节点

    Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...

  5. Leetcode Delete Node in a Linked List

    Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...

  6. Delete Node in a Linked List

    Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...

  7. 【4_237】Delete Node in a Linked List

    Delete Node in a Linked List Total Accepted: 48121 Total Submissions: 109297 Difficulty: Easy Write ...

  8. Leetcode-237 Delete Node in a Linked List

    #237.    Delete Node in a Linked List Write a function to delete a node (except the tail) in a singl ...

  9. (easy)LeetCode 237.Delete Node in a Linked List

    Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...

随机推荐

  1. msgpack的数据序列和还原

    msgpack的数据序列和还原 msgpack不仅可以序列一些常规的数据类型的数据,比如:string.datetime.integer...... 还能序列olevariant.stream 这就非 ...

  2. DotNetty 学习

    [转载]http://www.cnblogs.com/littlegod/p/7699482.html DotNetty的学习是带着如下这些问题展开: 1. Socket基础框架方案: 通信模式:异步 ...

  3. jQuery Ajax 上传文件夹及文件

    我们先来看一下文件夹结构 这是上传处理的: 看一下系统日志: 升级 HTML5文件实现拖拽上传提示效果改进(支持三种状态提示) 拖拽过程详解: 1:文件未拖出文件选择框的时候提示:将要上传的文件或文件 ...

  4. Svg.Js 简介(转)

    什么是SVG? SVG 指可伸缩矢量图形 (Scalable Vector Graphics) SVG 用来定义用于网络的基于矢量的图形 SVG 使用 XML 格式定义图形 SVG 图像在放大或改变尺 ...

  5. [转]Linux的SOCKET编程详解

    From : http://blog.csdn.net/hguisu/article/details/7445768 1. 网络中进程之间如何通信 进 程通信的概念最初来源于单机系统.由于每个进程都在 ...

  6. Reader 与 Guava MultiReader

    Reader是Java IO体系里字符处理读取流的基本类,代码如下 /* * %W% %E% * * Copyright (c) 2006, Oracle and/or its affiliates. ...

  7. frp错误处理:login to server failed: authorization failed

    frp使用过程中会出现各种错误信息,有些朋友不太清楚,打算记录一些常见的错误返回代码,这里介绍一下frpc客户端[W] [control.go:111] login to server failed: ...

  8. Go语言之高级篇beego框架安装与使用

    一.beego框架 1.beego框架简介 beego 是一个快速开发 Go 应用的 HTTP 框架,他可以用来快速开发 API.Web 及后端服务等各种应用,是一个 RESTful 的框架,主要设计 ...

  9. java 反射机制--根据属性名获取属性值

    1.考虑安全访问范围内的属性,没有权限访问到的属性不读取 /** * 根据属性名获取属性值 * * @param fieldName * @param object * @return */ priv ...

  10. 引用外部jquery.js

    使用 Google 的 CDN <head> <script type="text/javascript" src="http://ajax.googl ...