LeetCode_237. Delete Node in a Linked List
2016-01-08 15:12
573 查看
237. Delete Node in a Linked List
Total Accepted: 53467 TotalSubmissions: 121930 Difficulty: Easy
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 -> 4and you are given the third node with value
3, the linked
list should become
1 -> 2 -> 4after calling your function.
Subscribe to see which companies asked this question
删除链表的节点:刚开始题目理解错误,这题以前有个老师讲过类似的题目。
public void deleteNode(ListNode node) { node.val = node.next.val; node.next = node.next.next; }问题是这里的:
node.next = node.next.next;可不可以换成:
node = node.next;discuss 中给出了可能的原因:
哥哥没看懂!
相关文章推荐
- node应用场景
- node四大优势 转
- 从零开始nodejs系列文章-nodejs到底能干什么
- nodepad++使用技巧
- nodejs调用c++ addon的简单例子(带参数)
- datanode----nitialization failed for Block pool <registering> (Datanode Uuid unassigned) service to
- NodeJs中庸node-inspector调试
- NodeJS(四)Mac下如何安装package.json里面会产生依赖项
- [leetcode] 25. Reverse Nodes in k-Group 解题报告
- nodejs使用mongoose
- nodejs base64 编码解码
- nodejs音乐播放器
- 现在学习 JavaScript 的哪种技术更好:Angular、jQuery 还是 Node.js?(转)
- LeetCode Reverse Nodes in k-Group
- windows下node.js安装图文教程
- Node.js
- nodejs安装不了和npm安装不了的解决方法
- Nodejs·理解Buffer
- node运行报错: Error: listen EADDRINUSE :::3000 e
- node+express读书笔记1