[leetcode] Delete Node in a Linked List 删除链表中的一个结点
2015-08-13 22:22
567 查看
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
with value
题目大意:删除链表的一个节点,尾节点除外
Supposed the linked list is
1 -> 2 -> 3 -> 4and you are given the third node
with value
3, the linked list should become
1 -> 2 -> 4after calling your function.
题目大意:删除链表的一个节点,尾节点除外
/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ void deleteNode(struct ListNode* node) { { node->val = node->next->val; node->next = node->next->next; } }这应该是代码量最少的一道题了,两行代码
相关文章推荐
- Linux C函数参考手册(PDF版)
- 动易2006序列号破解算法公布
- Ruby实现的矩阵连乘算法
- C#插入法排序算法实例分析
- Lua教程(十七):C API简介
- 超大数据量存储常用数据库分表分库算法总结
- C#数据结构与算法揭秘二
- C#冒泡法排序算法实例分析
- 算法练习之从String.indexOf的模拟实现开始
- C#算法之关于大牛生小牛的问题
- C#实现打造气泡屏幕保护效果
- C#实现的算24点游戏算法实例分析
- C/C++数据对齐详细解析
- 利用C语言来求最大连续子序列乘积的方法
- c语言实现的带通配符匹配算法
- 浅析STL中的常用算法
- 字符串的组合算法问题的C语言实现攻略
- C 语言基础教程(我的C之旅开始了)[三]
- 算法之排列算法与组合算法详解