LeetCode Algorithms #237 <Delete Node in a Linked List>
2015-10-11 07:06
639 查看
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; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: void deleteNode(ListNode* node) { if(node->next == NULL || node == NULL) return; *node = *node->next; } };
相关文章推荐
- Node.js读书笔记
- 启动datanode后jps下无datanode的解决方法
- node-lessons
- nodejs API笔记
- nodejs基于art-template模板引擎生成
- hadoop2.2重新格式化namenode
- node.js实践第二天
- LeetCode Remove Nth Node From End of List
- Node.js学习技术栈
- Windows环境下的Nodejs+npm+bower安装步骤
- Nodejs中常用加密方式使用实例
- NodeJS、NPM安装配置步骤(windows版本)
- 解决windows 下 node-webkit 不能播放声音的问题
- 为什么我要用 Node.js? 案例逐一介绍
- Hadoop总结一:基础知识-Namenode,Datanode(非HA高可用性配置)
- node lesson6
- nodeclub
- 解决hadoop namenode 无法启动
- Node.js 中的copy
- node lesson5--async