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. jdbc初步(转)

    1. Jdbc的六个编程步骤 1. 注册一个驱动 注册驱动程序有三种方式: 方式一:Class.forName(“oracle.jdbc.driver.OracleDriver”); JAVA 规范中 ...

  2. thinkphp学习笔记10—看不懂的路由规则

    原文:thinkphp学习笔记10-看不懂的路由规则 路由这部分貌似在实际工作中没有怎么设计过,只是在用默认的设置,在手册里面看到部分,艰涩难懂. 1.路由定义 要使用路由功能需要支持PATH_INF ...

  3. laravel-安装验证码扩展

    第一步:找到验证码扩展 链接:https://packagist.org/packages/mews/captcha 第二步:安装 环境要求:验证码需要开启php的gd库 . 执行命令(有时候安装会出 ...

  4. P1563 玩具谜题(简单模拟)

    就是一个简单模拟 #include<iostream> #include<string> using namespace std; ; int in[maxn], x[maxn ...

  5. 布局管理器之BorderLayout(边界布局)

    边界布局管理器把容器的的布局分为五个位置:CENTER.EAST.WEST.NORTH.SOUTH.依次对应为:上北(NORTH).下南(SOUTH).左西(WEST).右东(EAST),中(CENT ...

  6. 【Pyton】【小甲鱼】类和对象:一些相关的BIF(内置函数)

    1.issubclass(class,classinfo) 1)一个类被认为是其自身的子类 2)classinfo可以使类对象组成的元祖,只要class与其中任何一个候选类的子类,则返回True. & ...

  7. nyoj最少乘法次数——快速幂思想

    最少乘法次数 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 给你一个非零整数,让你求这个数的n次方,每次相乘的结果可以在后面使用,求至少需要多少次乘.如24:2*2 ...

  8. EF配置文件初始化数据库 codefirst

    . using ConsoleApplication42; using System.Data.Entity; using System.Data.Entity.ModelConfiguration. ...

  9. ExpandListView onChildClickListener 失效

    http://stackoverflow.com/questions/11529472/expandablelistview-onchildclicklistener-not-work 首先声明:   ...

  10. [Navicat] 常用快捷键及注意事项

    近来需要同时管理多种类型.多台server的数据库,在经历了各种查询客户端(SSMS, SQLyog, PL/SQL等)的不断切换,ip/user/pwd的反复输入的这种自虐式体验后,实在无法忍受,就 ...