LintCode 第452题 删除链表中的元素
来源:互联网 发布:ubuntu 查看mysql状态 编辑:程序博客网 时间:2024/06/05 22:41
题目描述:
删除链表中等于给定值val
的所有节点。
样例
给出链表 1->2->3->3->4->5->3
, 和 val = 3
, 你需要返回删除3之后的链表:1->2->4->5
。
#include <iostream>//链表结点结构struct Node { int value; struct Node * next;};//创建单链表struct Node * creatLink(int n) { struct Node * pHead = NULL; for (int i = n; i>0; i--) { struct Node * p = (struct Node *)malloc(sizeof(struct Node)); p->value = i; p->next = pHead; pHead = p; } return pHead;}//移除指定节点void removeLink(struct Node* pHead,int removeValue) { if (pHead->next->value != removeValue) { removeLink(pHead->next,removeValue); } else { pHead->next = pHead->next->next; }}int main(int argc, const char * argv[]) { // insert code here... std::cout << "Hello, World!\n"; struct Node * pHead = creatLink(5); removeLink(pHead,3); return 0;}
阅读全文
0 0
- LintCode 第452题 删除链表中的元素
- (lintcode)第452题删除链表中的元素
- LintCode 第452题 删除链表中的元素
- LintCode 452 删除链表中的元素
- lintcode 452 删除链表中的元素
- LintCode:删除链表中的元素452
- [Lintcode] #452 删除链表中的元素
- LintCode-删除链表中的元素
- LintCode之删除链表中的元素
- 【Lintcode】删除链表中的元素
- LintCode【入门】删除链表中的元素
- lintcode(E) 删除链表中的元素
- lintcode-入门-删除链表中的元素
- LintCode 删除链表中的元素
- LintCode 删除链表中的元素
- 删除链表中的元素-LintCode
- Lintcode 452.删除链表中的元素
- LintCode : 删除链表中的重复元素
- Hibernate入门学习(6)----hbm配置文档
- Linux内核移植(1)
- 大数相加/减/乘/除/取余 模板
- java基础代码----根据日期字符串 查找对应的周期的起始位置和结束位置
- tensorflow学习笔记: variable scope
- LintCode 第452题 删除链表中的元素
- angular4: Unhandled Promise rejection Cannot assign to a reference or variable
- R语言rdom包简介
- 浏览器拦截新窗口打开的问题
- springcloud(一):大话Spring Cloud
- Socket与Serversocket的写出问题
- java 面向对象
- OpenStack-M版(Mitaka)搭建基于(Centos7.2)+++十二、Openstack编排服务服务(heat)
- Integer和int的区别