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.

/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
void deleteNode(struct ListNode* node) {
if(node == NULL)
{
return;
}
node->val = node->next->val;
node->next = node->next->next;
}

Leetcode237:Delete Node in a Linked List的更多相关文章

  1. 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 ...

  2. LeetCode OJ: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 ...

  3. 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 ...

  4. 237. Delete Node in a Linked List(C++)

    237. Delete Node in a Linked Lis t Write a function to delete a node (except the tail) in a singly l ...

  5. [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 ...

  6. 237. Delete Node in a Linked List【easy】

    237. Delete Node in a Linked List[easy] Write a function to delete a node (except the tail) in a sin ...

  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. [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 ...

  9. 【LeetCode】237 & 203 - Delete Node in a Linked List & Remove Linked List Elements

    237 - Delete Node in a Linked List Write a function to delete a node (except the tail) in a singly l ...

随机推荐

  1. Qt之QNetworkInterface

    简述 QNetworkInterface类负责提供主机的IP地址和网络接口的列表. QNetworkInterface表示了当前程序正在运行时与主机绑定的一个网络接口.每个网络接口可能包含0个或多个I ...

  2. LA 3213 Ancient Cipher

    开始我理解错题意了,应该是这样理解的: 字符串1进行映射后可以做一个置换,若置换后与字符串2相同,也是输出YES的 比如ABCA 和 DDEF 因此我们需要做的就是统计有多少类字母,每一类有多少个,如 ...

  3. ASP.NET MVC 4 WebAPI. Support Areas in HttpControllerSelector

    This article was written for ASP.NET MVC 4 RC (Release Candidate). If you are still using Beta versi ...

  4. Scrum&Kanban在移动开发团队的实践 (二)

    Scrum&Kanban在移动开发团队的实践系列: Scrum&Kanban在移动开发团队的实践 (一) Scrum&Kanban在移动开发团队的实践 (二) 在第一篇分享文章 ...

  5. 深入理解ob_flush/flush

    ob_flush/flush在手册中的描述, 都是刷新输出缓冲区, 并且还需要配套使用, 所以会导致很多人迷惑… 其实, 他们俩的操作对象不同, 有些情况下, flush根本不做什么事情.. ob_* ...

  6. 【Python】入门 list有些不懂

    # -*- coding: utf-8 -*- # -*- coding: cp936 -*- 首行加这个 代码里就可以加注释 raw_input("Press Enter Exit&quo ...

  7. phonegap配置启动动画

    以下有2种方式 1 主Active中 onCreate函数里添加代码 2 config.xml文件进行配置(对通过命令行模式下cordova命令行生成的可行) 确保自己安装了SplashScreen插 ...

  8. Xtrabackup流备份与恢复

    Xtrabackup是MySQL数据库的备份不可多得的工具之一.提供了全备,增备,数据库级别,表级别备份等等.最牛X的还有不落盘的备份,即流备份方式.对于服务器上空间不足,或是搭建主从,直接使用流式备 ...

  9. 【转】Git连接oschina管理代码版本

    原文网址:http://blog.csdn.net/liukang325/article/details/24051467 工作中一般都是用的SVN,最近好像GitHub有些火,看到开源中国上也有Gi ...

  10. Android 动画 6问6答

    1.view 动画有哪些需要注意的? 答:view动画 本身比较简单.http://www.cnblogs.com/punkisnotdead/p/5179115.html 看这篇文章的第五问就可以了 ...