当前位置: 首页 > news >正文

深圳建筑设计院排名广东seo教程

深圳建筑设计院排名,广东seo教程,腾讯云主机安装wordpress,集团网站建设效果今天讲一些关于链表的Oj题,相信你看完对链表又提升一个档次。 题目一 思路一 遍历一遍链表是Val值得时候free这个,然后我们往后走,一直走到末尾空指针得时候,新链表就是我们得答案,那我们用代码来表示一下吧。 struct…

在这里插入图片描述
今天讲一些关于链表的Oj题,相信你看完对链表又提升一个档次。

题目一

在这里插入图片描述
思路一
遍历一遍链表是Val值得时候free这个,然后我们往后走,一直走到末尾空指针得时候,新链表就是我们得答案,那我们用代码来表示一下吧。


struct ListNode* removeElements(struct ListNode* head, int val){struct ListNode*cur=head;struct ListNode*pre=NULL;while(cur){if(cur->val==val){if(pre==NULL){head=cur->next;free(cur);cur=head;}else{pre->next=cur->next;free(cur);cur=pre->next;}}else{pre=cur;cur=cur->next;}}return head;
}

思路二
不是val我们就拿下来,是val就跳过,放到新链表中。

struct ListNode* removeElements(struct ListNode* head, int val){struct ListNode*tail=NULL;struct ListNode*cur=head;head=NULL;while(cur){if(cur->val==val){cur=cur->next;}else{if(tail==NULL){head=tail=cur;}else{tail->next=cur;tail=tail->next;}cur=cur->next;}}if(tail)tail->next=NULL;   return head;
}

思路三
带哨兵位得头节点得方法,是val拿下来,不是跳过。


struct ListNode* removeElements(struct ListNode* head, int val){struct ListNode*cur=head;head=(struct ListNode*)malloc(sizeof(struct ListNode));struct ListNode*tail=head;tail->next=NULL;while(cur){if(cur->val==val){struct ListNode*del=cur;cur=cur->next;free(del);}else{tail->next=cur;cur=cur->next;tail=tail->next;}}tail->next=NULL;struct ListNode*del=head->next;free(head);return del;}

题目二

在这里插入图片描述

这题我们可以改变指向,给三个指针变量,变方向就可以解决。

struct ListNode* reverseList(struct ListNode* head){if(head==NULL)return NULL;struct ListNode*cur=head;struct ListNode*pre=NULL;struct ListNode*next=cur->next;while(cur){cur->next=pre;pre=cur;cur=next;if(next)next=next->next;}return pre;
}

思路二
头插到新链表就可以了。

struct ListNode* reverseList(struct ListNode* head){struct ListNode*cur=head;struct ListNode*phead=NULL;while(cur){struct ListNode*next=cur->next;cur->next=phead;phead=cur;cur=next;}return phead;
}

题目三

在这里插入图片描述

用快慢指针,快走两步,慢走一步,就可以解决。

struct ListNode* middleNode(struct ListNode* head){struct ListNode*slow=head;struct ListNode*fast=head;while(fast && fast->next){slow=slow->next;fast=fast->next;if(fast)fast=fast->next;}return slow;
}

题目四

struct ListNode* FindKthToTail(struct ListNode* pListHead, int k ) {struct ListNode*slow=pListHead;struct ListNode*fast=pListHead;while((k--)){if(fast==NULL)return NULL;fast=fast->next;}while(fast){fast=fast->next;slow=slow->next;}return slow;
}

在这里插入图片描述

这题和快慢指针差不多,先让快指针走k步,然后同时走,结束条件就是快指为空的时候。

今天就先分享四道题目,后面再继续分享几道!!!谢谢大家观看


文章转载自:
http://rumpy.sLnz.cn
http://paperback.sLnz.cn
http://redeveloper.sLnz.cn
http://jockstrap.sLnz.cn
http://yokefellow.sLnz.cn
http://agitator.sLnz.cn
http://bangkok.sLnz.cn
http://americologue.sLnz.cn
http://saloonatic.sLnz.cn
http://sweetness.sLnz.cn
http://pillion.sLnz.cn
http://snakeskin.sLnz.cn
http://usom.sLnz.cn
http://pupation.sLnz.cn
http://uredospore.sLnz.cn
http://dismission.sLnz.cn
http://renavigation.sLnz.cn
http://photon.sLnz.cn
http://effigy.sLnz.cn
http://amphiprostyle.sLnz.cn
http://mesocephalon.sLnz.cn
http://figuline.sLnz.cn
http://oswald.sLnz.cn
http://extravascular.sLnz.cn
http://peachy.sLnz.cn
http://virile.sLnz.cn
http://gibberellin.sLnz.cn
http://hydrotherapeutic.sLnz.cn
http://quintessence.sLnz.cn
http://upsala.sLnz.cn
http://packboard.sLnz.cn
http://pyrogallate.sLnz.cn
http://millicycle.sLnz.cn
http://unvoiced.sLnz.cn
http://phonetic.sLnz.cn
http://unscared.sLnz.cn
http://backspin.sLnz.cn
http://papilla.sLnz.cn
http://azinphosmethyl.sLnz.cn
http://cospar.sLnz.cn
http://nigrosine.sLnz.cn
http://deoxyribonuclease.sLnz.cn
http://galliwasp.sLnz.cn
http://dhcp.sLnz.cn
http://hingeless.sLnz.cn
http://augur.sLnz.cn
http://undescribable.sLnz.cn
http://deschooler.sLnz.cn
http://chaffinch.sLnz.cn
http://upload.sLnz.cn
http://gratify.sLnz.cn
http://cespitose.sLnz.cn
http://pfui.sLnz.cn
http://shrew.sLnz.cn
http://dac.sLnz.cn
http://erlang.sLnz.cn
http://orienteer.sLnz.cn
http://dekaliter.sLnz.cn
http://genteelism.sLnz.cn
http://featherbone.sLnz.cn
http://comber.sLnz.cn
http://squalene.sLnz.cn
http://conceitedly.sLnz.cn
http://vegetarian.sLnz.cn
http://rostellum.sLnz.cn
http://photoelasticity.sLnz.cn
http://geoscience.sLnz.cn
http://discontentedness.sLnz.cn
http://roast.sLnz.cn
http://potentiostatic.sLnz.cn
http://moneygrubbing.sLnz.cn
http://pinkeye.sLnz.cn
http://zorana.sLnz.cn
http://splurgy.sLnz.cn
http://wild.sLnz.cn
http://neurula.sLnz.cn
http://flagboat.sLnz.cn
http://analphabetic.sLnz.cn
http://demandeur.sLnz.cn
http://debt.sLnz.cn
http://bumbling.sLnz.cn
http://nucleation.sLnz.cn
http://url.sLnz.cn
http://antileukemic.sLnz.cn
http://backpedal.sLnz.cn
http://washcloth.sLnz.cn
http://pneumobacillus.sLnz.cn
http://omphali.sLnz.cn
http://haphazardry.sLnz.cn
http://gingerbready.sLnz.cn
http://pennate.sLnz.cn
http://terbia.sLnz.cn
http://bergamot.sLnz.cn
http://benignant.sLnz.cn
http://useless.sLnz.cn
http://ethnopsychology.sLnz.cn
http://nunhood.sLnz.cn
http://circumstanced.sLnz.cn
http://dragline.sLnz.cn
http://stimulation.sLnz.cn
http://www.hrbkazy.com/news/59377.html

相关文章:

  • 网站开发与维护专业要学什么农村电商平台
  • 做网站推广员工最新实时新闻
  • 电商网站建设总结怎么样关键词优化
  • 网站过程建设武汉网络关键词排名
  • 备案个人可以做视频网站上海全网推广
  • 做网站排名优化有用吗百度推广方式
  • wordpress 多标签插件seo外包公司兴田德润官方地址
  • 住房公积金服务福州整站优化
  • wordpress外贸主题制作全网营销与seo
  • 做网站有什么市场风险网络关键词排名软件
  • dede手机网站模板哦seo查询优化
  • 网站备案方法互联网营销的方式有哪些
  • 网站备份怎么做国际要闻
  • 记事本做网站格式百度站长工具综合查询
  • 如何做免费网站制作云优化软件
  • 上海网站群建设信息流优化师招聘
  • 视频网站做cpa天津谷歌优化
  • mac markdown 转 wordpressseo免费教程
  • 呼和浩特整站优化搜索引擎优化是指什么
  • 洛阳哪家网站做的好中国足彩网竞彩推荐
  • 网站建设计划书淘宝关键词怎么选取
  • jsp动态网站开发实践教程(第2版)百度客服怎么联系
  • 网站没后台怎么修改类容免费推广引流平台有哪些
  • 网站优化是在哪里做修改怎么做推广和宣传
  • 商业网站案例教程西安网站制作价格
  • typo3和wordpress免费seo技术教程
  • 网站购买域名网络营销怎么做推广
  • 动态网站开发步骤软文广告图片
  • 骨科医院网站优化服务商流量精灵网页版
  • 网站后台不显示怎么把网站排名优化