#leetcode#237. Delete Node in a Linked List
2016-04-07 21:05
585 查看
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
the linked list should become
给了单个节点,然后删除。
熟悉链表操作
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==NULL) return; node->val=node->next->val; node->next=node->next->next; } };
相关文章推荐
- [置顶] windows上node-webkit安装sqlite、socket的那些坑
- 简单理解 unix (liunx)inode
- 关于childNodes及children的区别(图文结合)
- node使用buffer生成图片
- DataNode本地数据存储和管理--ncp_block_verification.log.curr和dncp_block_verification.log.prev
- inode 及软链接、硬链接
- hadoop SecondNamenode
- node.js第一步
- Hadoop集群所有的DataNode都启动不了解决办法
- Namenode HA原理详解(脑裂)
- win系统下nodejs安装及环境配置
- inode及硬链接和软链接
- Node.js简单介绍
- inode 、软(硬)链接及fork与vfork
- nodejs小记之jqueryfileupload异步图片文件上传 带上传进度
- node.js系统找不到指定文件报错
- nw.js node-webkit系列(20)拖动文件到页面并读取文件信息
- 237. Delete Node in a Linked List
- nodejs小记之formidable同步图片文件上传
- node基础再现--module.exports 和exports