Leetcode: Delete Node in a Linked List
2015-12-20 08:16
726 查看
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.
public class Solution { public void deleteNode(ListNode node) { if(node != null && node.next != null) { node.val = node.next.val; node.next = node.next.next; } } }
相关文章推荐
- LeetCode - Remove Nth Node From End of List
- VS 2008 也能玩转 Node.JS!
- 237. Delete Node in a Linked List
- nodejs学习[持续更新]
- 深入浅析Node.js 事件循环
- Delete Node in a Linked List
- Modernizr.js和yepnode.js
- leetcode刷题日记——Delete Node in a Linked List
- nodejs中命令行中参数的获取和解析
- 如何屏蔽nodejs里的/favicon.ico请求
- Leetcode: Count Complete Tree Nodes
- 【leetcode题解】【E】【61.5】Remove Nth Node From End of List
- [Node.js] 使用node-forge保障Javascript应用的传输安全
- node.js环境配置
- Ext系列文件系统inode和block详解
- leetcode -- Count Complete Tree Nodes -- 重点。BFS
- Android系统编译环境初始化时Product产品的import-nodes过程
- 解决NodeJs gm模块报错{ [Error: Command failed: aaЧaaaa ] code: 4, signal: null }
- Nodejs解决2分钟限制
- nodejs基础 -- web模块