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

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

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. C++获取和设置时区

    一.     获取当前系统时区信息 使用API函数GetTimeZoneInformation可以获得当前时区的相关信息,函数原型为 DWORD GetTimeZoneInformation( LPT ...

  2. Navicat Premium 12.1.7.0安装与激活

    原文:https://www.jianshu.com/p/5f693b4c9468 Navicat Premium 12.1.8.0安装与激活 丿记忆灬永殇丨 关注 2018.01.20 13:43* ...

  3. 让DELPHI自带的richedit控件显示图片

    让DELPHI自带的richedit控件显示图片 unit RichEx; { 2005-03-04 LiChengbin Added: Insert bitmap or gif into RichE ...

  4. iphone6/6+ 适配心得

    1.     文档综述 自iphone6/6+发布,ios屏幕分辨率的种类一下从2种变成了四种.对于以前很多手写UI,并且使用绝对坐标的UI,可能会发生异变,本文主要介绍在纯手写UI条件下,ios应用 ...

  5. AOP拦截器 表达式写法

    Pointcut 是指那些方法需要被执行"AOP",是由"Pointcut Expression"来描述的.Pointcut可以有下列方式来定义或者通过& ...

  6. linux dig命令 转

    dig 命令主要用来从 DNS 域名服务器查询主机地址信息. 查询单个域名的 DNS 信息 dig 命令最典型的用法就是查询单个主机的信息. $ dig baidu.com dig 命令默认的输出信息 ...

  7. 修复android下webView控件的总结

    游戏中有一个收集玩家问题反馈的网页,很早之前就有同事反映说android在游戏无法上传附件,在浏览器中是可以正常使用的.最近能腾出手来的时候,就仔细看了一下这个问题,发现很里藏着不少问题,这里一一记录 ...

  8. 安卓开发(Java)中关于final关键字与线程安全性

    前言 学习新知识固然重要,但是时常往回看看,温故知新是很必要的.回顾一下线程安全性和final关键字. 正文 从Java 5开始,final keyword一个特殊用法是在并发库中一个非常重要且经常被 ...

  9. idea jni

    javah -jni -classpath (搜寻类目录) -d (输出目录) (类名) nm -D  **.so idea setting $JDKPath$/bin/javah -jni -cla ...

  10. android BitmapDrawable的使用

    <span style="font-size:18px;"> //功能:显示缩略图,大小为40*40 //通过openRawResource获取一个inputStrea ...