LeeCode-Delete Node in a Linked List
2015-07-20 09:08
656 查看
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
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; * struct ListNode *next; * }; */ void deleteNode(struct ListNode* node) { if(node==NULL) return; struct ListNode* p,*q; q=node; p=node->next; int temp; temp=p->val; p->val=q->val; q->val=temp; q->next=p->next; }
相关文章推荐
- nodejs之async异步编程
- PHP vs Node.js
- NodeJS async实例详解:When to use what?
- ECMAScript 6教程 (二) 对象和函数
- Node JS文件操作fs
- Remove Nth Node From End of List
- Node JS 模块
- Permission denied: user=Administrator, access=WRITE, inode="hadoop":hadoop:supergroup:rwxr-xr-x
- Delete Node in a Linked List
- 【leetcode】Delete Node in a Linked List
- Node:Trie数(字典树)
- secondarynamenode无法启动
- node.js乱码
- 多次格式化namenode,datanode无法启动的解决办法
- #25 Reverse Nodes in k-Group
- Swap Nodes in Pairs
- node模块的载入及机制
- node及npm安装过程中的win环境变量设置
- Node:KMP之next数组
- [CareerCup] 2.3 Delete Node in a Linked List 删除链表的节点