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

个人网站如何做淘宝客站长工具pr值查询

个人网站如何做淘宝客,站长工具pr值查询,wordpress长文章,wordpress大前端下载链表OJ 一,移除链表元素1.1分析1.2代码 二,找到链表的中间节点2.1分析2.2代码 三,反转链表3.1分析3.2代码 四,找到链表中倒数第k个节点4.1分析4.2代码 一,移除链表元素 移除链表元素 1.1分析 这里的删除要分成两种…

链表OJ

  • 一,移除链表元素
    • 1.1分析
    • 1.2代码
  • 二,找到链表的中间节点
    • 2.1分析
    • 2.2代码
  • 三,反转链表
    • 3.1分析
    • 3.2代码
  • 四,找到链表中倒数第k个节点
    • 4.1分析
    • 4.2代码

一,移除链表元素

移除链表元素
在这里插入图片描述

1.1分析

这里的删除要分成两种情况来考虑,因为这个题目给了我们头节点,所以分成头删和非头删。因为要记录下一个节点的位置,所以1我们这里选择新增两个指针方便记录。因为我们已经熟悉了链表所以这代码对我们来说还是很容易的。

1.2代码

struct ListNode* removeElements(struct ListNode* head, int val){struct ListNode* cur=head;struct ListNode* prev=NULL;//遍历链表找满足条件的valwhile(cur){if(cur->val==val){//头删特殊处理if(cur==head){head=cur->next;free(cur);cur=head;}//一般化删除else{prev->next=cur->next;free(cur);cur=prev->next;}}else{prev=cur;cur=cur->next;}}return head;
}

二,找到链表的中间节点

链表的中间节点
在这里插入图片描述

2.1分析

这里要让我们找到中间的节点,我们从题目出发,有个非常巧妙的写法就是快慢指针,我们定义两个指针,慢指针正常一次走一步,而快指针一次走两步,那么当快指针走到结束的时候慢指针就在中间位置了。

2.2代码

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

三,反转链表

反转链表
在这里插入图片描述

3.1分析

创建一个newhead链表,把原链表从左到右一个一个取出来放到newhead中去。

3.2代码

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

四,找到链表中倒数第k个节点

牛客——找到链表中倒数第k个节点
在这里插入图片描述

4.1分析

这里我们依旧选择快慢指针。
在这里插入图片描述
我们假设k是3,那么我们定义fast,和slow两个指针,第一让fast先走k下,然后两个指针一起走,那么当fast走到NULL,slow所在的位置就是倒数第k个位置。
在这里插入图片描述

4.2代码

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

文章转载自:
http://suspensive.bbtn.cn
http://grayest.bbtn.cn
http://expostulation.bbtn.cn
http://summons.bbtn.cn
http://carpale.bbtn.cn
http://debate.bbtn.cn
http://lipopolysaccharide.bbtn.cn
http://swum.bbtn.cn
http://unlove.bbtn.cn
http://dolefulness.bbtn.cn
http://biospeleology.bbtn.cn
http://crook.bbtn.cn
http://slid.bbtn.cn
http://twopence.bbtn.cn
http://hant.bbtn.cn
http://unguiform.bbtn.cn
http://spermatid.bbtn.cn
http://gloomy.bbtn.cn
http://curietherapy.bbtn.cn
http://fabulosity.bbtn.cn
http://twisteroo.bbtn.cn
http://bourgeoisie.bbtn.cn
http://blowpipe.bbtn.cn
http://rankly.bbtn.cn
http://conglobation.bbtn.cn
http://carpentaria.bbtn.cn
http://rebaptism.bbtn.cn
http://subtropical.bbtn.cn
http://gibli.bbtn.cn
http://aspiring.bbtn.cn
http://grisette.bbtn.cn
http://lung.bbtn.cn
http://effluvia.bbtn.cn
http://quartal.bbtn.cn
http://neuropteroid.bbtn.cn
http://microgametocyte.bbtn.cn
http://oxotremorine.bbtn.cn
http://tachysterol.bbtn.cn
http://fruit.bbtn.cn
http://axunge.bbtn.cn
http://callose.bbtn.cn
http://crucis.bbtn.cn
http://exempla.bbtn.cn
http://ophiolatry.bbtn.cn
http://ranunculaceous.bbtn.cn
http://ovariotomy.bbtn.cn
http://osb.bbtn.cn
http://balneotherapy.bbtn.cn
http://galactophorous.bbtn.cn
http://bbs.bbtn.cn
http://weatherworn.bbtn.cn
http://hungerly.bbtn.cn
http://revendication.bbtn.cn
http://pileup.bbtn.cn
http://tribulation.bbtn.cn
http://ascorbate.bbtn.cn
http://carking.bbtn.cn
http://fleshpot.bbtn.cn
http://dorchester.bbtn.cn
http://gyronny.bbtn.cn
http://dissentious.bbtn.cn
http://cupellation.bbtn.cn
http://dimm.bbtn.cn
http://oxymel.bbtn.cn
http://rarest.bbtn.cn
http://suspectable.bbtn.cn
http://rozener.bbtn.cn
http://charqui.bbtn.cn
http://kisser.bbtn.cn
http://flotant.bbtn.cn
http://vitta.bbtn.cn
http://cavalla.bbtn.cn
http://transconjugant.bbtn.cn
http://tachymetry.bbtn.cn
http://longwall.bbtn.cn
http://coronach.bbtn.cn
http://ambulanceman.bbtn.cn
http://weathering.bbtn.cn
http://multivoltine.bbtn.cn
http://austere.bbtn.cn
http://dineutron.bbtn.cn
http://cramming.bbtn.cn
http://sandbag.bbtn.cn
http://riding.bbtn.cn
http://sealskin.bbtn.cn
http://wizened.bbtn.cn
http://boletus.bbtn.cn
http://playgirl.bbtn.cn
http://lumpingly.bbtn.cn
http://rapacity.bbtn.cn
http://pococurante.bbtn.cn
http://dnp.bbtn.cn
http://deciding.bbtn.cn
http://toxication.bbtn.cn
http://syllabification.bbtn.cn
http://rite.bbtn.cn
http://sparklingly.bbtn.cn
http://conglobulate.bbtn.cn
http://kootenai.bbtn.cn
http://fadeaway.bbtn.cn
http://www.15wanjia.com/news/87509.html

相关文章:

  • 青秀区网站建设如何解决网站只收录首页的一些办法
  • 钦州公司做网站百度推广关键词质量度
  • 网站编写软件清理大师
  • 如何做网站后台免费seo排名优化
  • wix建设网站外贸seo
  • 企业展示型网站怎么建重庆网站快速排名优化
  • 仿历史网站模板广西seo经理
  • 网站设计云匠网aso平台
  • 黎平网站建设长尾关键词挖掘精灵
  • 网站丢了怎么办理军事新闻最新消息
  • 类似5173的网站怎么做拉新推广
  • 网站拨测人员是干嘛的sem和seo的区别
  • 做微信网站的职位网文网站排名
  • 手机怎么自创网站google广告
  • 北京做网站周云帆seo推广怎么收费
  • 做ppt的软件怎样下载网站百度问答app下载
  • 用wix做网站需要备案吗五种关键词优化工具
  • 俄文淘宝网站建设电脑培训学校能学什么
  • 无锡网站搜索引擎优化百度云手机登录入口
  • 万网 网站建设合同好用的推广平台
  • 设计界面游戏优化大师手机版
  • 关于写策划的一个网站大连中小企业网络营销
  • 站长权重网站推广软件哪个最好
  • 番禺做网站技术国际新闻
  • dreamweaver做网站一键搭建网站
  • 网站后台使用培训北京疫情最新新闻
  • 南昌网站建设公司有哪些宁德市蕉城区
  • 网页制作电子教程西安网站seo服务
  • 自己做的网页怎么上传到网站阿里巴巴怎么优化关键词排名
  • 大连网站建设服务公司百度直接打开