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 ...
随机推荐
- AsyncTask实现下载图片
实现效果: /*采用异步任务 AsyncTask<String,Integer, byte[]> * 参数一代表 执行异步任务时传递的参数的类型 * 参数二 如果不采用进度,则填Vo ...
- 【iOS开发-66】QQ设置界面的案例:利用storyboard开发静态的tableView界面,核心是Static Cells
(1)效果 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvd2Vpc3ViYW8=/font/5a6L5L2T/fontsize/400/fill/I0JB ...
- Jquery面试题整合
来自棱镜学院-在线IT教育 www.prismcollege.com 一.Jquery測试题 以下哪种不是jquery的选择器?(单选) A.基本选择器 B.后代选择器 C.类选择器 D.进一 ...
- ios打包应用程序,生成ipa文件
假设我的程序调试好了,怎么才干发给别人用呢?正常情况下IPA文件是从Xcode的Organizer中输出的,可是我们没有证书,这样输出会产生错误. 以下教你怎样生成ipa文件: 1.到你当前proje ...
- js校验
判空 function check(s) { return (s == null || typeof (s) == "undefined" || s == "" ...
- Android学习笔记--JNI的使用方法
1.JNI是什么 JNI是Java Native Interface的缩写,它提供若干的API实现Java与其他语言之间的通信.而Android Framework由基于Java语言的的Java层与基 ...
- xUtils的文件下载与安装,xUtils的文件上传
开篇报错注意:本教程是基于xUtils-2.6.14.jar版本实现的 由于studio中6.0以后安卓取消了httpclient,而xutils则基于httpclient开发的,所以现在无法使用,将 ...
- BlockingQueue
BlockingQueue的使用 http://www.cnblogs.com/liuling/p/2013-8-20-01.html BlockingQueue深入分析 http://blog.cs ...
- c++设计模式之策略模式
概念:通过定义一系列封装的算法,使得调度者可以互相替换,此模式让算法的变化,不会影响到使用算法的客户. 特点: 1)根据不同的情况创建不同的对象. 2)每个对象的方法名相同,但实现却不同. 结构: 1 ...
- codeforces 337D Book of Evil(dp)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Book of Evil Paladin Manao caught the tra ...