LeeCode-Delete Node in a Linked List
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.
/**
* 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; }
LeeCode-Delete Node in a Linked List的更多相关文章
- 【4_237】Delete Node in a Linked List
Delete Node in a Linked List Total Accepted: 48121 Total Submissions: 109297 Difficulty: Easy Write ...
- Leetcode-237 Delete Node in a Linked List
#237. Delete Node in a Linked List Write a function to delete a node (except the tail) in a singl ...
- [CareerCup] 2.3 Delete Node in a Linked List 删除链表的节点
2.3 Implement an algorithm to delete a node in the middle of a singly linked list, given only access ...
- 【LeetCode】237 & 203 - Delete Node in a Linked List & Remove Linked List Elements
237 - Delete Node in a Linked List Write a function to delete a node (except the tail) in a singly l ...
- 237. Delete Node in a Linked List(C++)
237. Delete Node in a Linked Lis t Write a function to delete a node (except the tail) in a singly l ...
- [LeetCode] 237. Delete Node in a Linked List 解题思路
Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...
- LeetCode Javascript实现 283. Move Zeroes 349. Intersection of Two Arrays 237. Delete Node in a Linked List
283. Move Zeroes var moveZeroes = function(nums) { var num1=0,num2=1; while(num1!=num2){ nums.forEac ...
- 237. Delete Node in a Linked List【easy】
237. Delete Node in a Linked List[easy] Write a function to delete a node (except the tail) in a sin ...
- LeetCode_237. Delete Node in a Linked List
237. Delete Node in a Linked List Easy Write a function to delete a node (except the tail) in a sing ...
- [LeetCode] Delete Node in a Linked List 删除链表的节点
Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...
随机推荐
- Java Fuck Bignumber
为了熟悉java , 开一套poj大数处理的题来写. ------------------------------------------------------------------- A: (1 ...
- UVa156.Ananagrams
题目连接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- OpenStack Mixture HypervisorsDriver configure and implementation theory
通过本文,您将可以了解在 OpenStack 中如何进行混合 Hypervisor 的配置及其实现原理的基本分析.本文主要结合作者在 Nova 中的实际开发经验对 OpenStack 中混合 Hype ...
- sql求和涉及到null值
SQL ISNULL().NVL().IFNULL() 和 COALESCE() 函数 请看下面的 "Products" 表: P_Id ProductName UnitPrice ...
- 表单验证插件jquery.validate的使用方法演示
jQueryValidate表单验证效果 jquery.validate验证错误信息的样式控制 <!--validate验证插件的基础样式--> input.error{border: 1 ...
- hdu1171 Big Event in HDU 01-背包
转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1171 Problem ...
- Android窗口管理服务WindowManagerService对壁纸窗口(Wallpaper Window)的管理分析
文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/8550820 Android系统中,壁纸窗口和输 ...
- 前端--关于javascript对象
在javascript中对象是一种基本的数据类型,在数据结构上是一种散列表,可以看作是属性的无序集合,除了原始值其他一切都是对象.它可以用来表示现实世界中或者我们大脑中抽象出来的客体,这和其他面向对象 ...
- Android Studio 导入Eclipse工程
eclipse:workspace对应多个project:而android studio是project对应多个module:故,在android studio中的工程project实际上是eclip ...
- 几句话弄清楚Java参数传值还是传引用
最近刷题做了一些算法题,对于在递归函数调用的时候什么时候传入值,什么时候传入引用有疑问,在网上搜索了一下,得出了一下三条总结: 1.对象就是传引用 2.原始类型就是传值 3.String,Intege ...