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

做网站用到什么开发语言app推广联盟

做网站用到什么开发语言,app推广联盟,辽宁建设工程质量监督站网站,昆山专业简历制作网站文章目录 💡题目分析💡解题思路🚩步骤一:拷贝节点插入到原节点的后面🍩步骤一代码 🚩步骤二:控制拷贝节点的random进行连接🍩步骤二代码 🚩步骤三:拷贝节点解…

在这里插入图片描述

文章目录

  • 💡题目分析
  • 💡解题思路
    • 🚩步骤一:拷贝节点插入到原节点的后面
      • 🍩步骤一代码
    • 🚩步骤二:控制拷贝节点的random进行连接
      • 🍩步骤二代码
    • 🚩步骤三:拷贝节点解下来尾插 组成拷贝链表,恢复原链表
      • 🍩步骤三代码
  • 🔔接口源码

在这里插入图片描述
题目链接👉 LeetCode 138.复制带随机指针的链表👈

💡题目分析

给你一个长度为 n 的链表,每个节点包含一个额外增加的随机指针 random ,该指针可以指向链表中的任何节点或空节点。

构造这个链表的 深拷贝。 深拷贝应该正好由 n 个 全新 节点组成,其中每个新节点的值都设为其对应的原节点的值。新节点的 next 指针和 random 指针也都应指向复制链表中的新节点,并使原链表和复制链表中的这些指针能够表示相同的链表状态。复制链表中的指针都不应指向原链表中的节点 。

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

💡解题思路

🚩步骤一:拷贝节点插入到原节点的后面

🍄初始情况:
在这里插入图片描述

①先将链表拷贝一层,让头指针cur的next指向一个新创建的拷贝节点,并将拷贝节点的next指向cur没发生变化之前的next。即在每个节点的后面再插入一个与他相同的节点。
在这里插入图片描述
cur一直向后走,一直重复①步骤即可得到拷贝节点(图中米黄色线条)
在这里插入图片描述

🍩步骤一代码

	//1、拷贝节点插入在原节点的后面struct Node* cur = head;while(cur){struct Node* copy = (struct Node*)malloc(sizeof(struct Node));copy->val = cur->val;struct Node* next = cur->next;//插入cur->next = copy;copy->next = next;cur = next;}

🚩步骤二:控制拷贝节点的random进行连接

②再将拷贝链表的random进行连接,由于原链表中每个节点的next都是拷贝链表中的节点,因此再将原链表中节点的random给拷贝链表的过程中,只需给random的next即可(copy->random = cur->random->next;)(图中紫色线条)
在这里插入图片描述

🍩步骤二代码

	//2、控制拷贝节点的randomcur = head;while(cur){struct Node* copy = cur->next;if(cur->random == NULL){copy->random = NULL;}else{copy->random = cur->random->next;}cur = copy->next;}

🚩步骤三:拷贝节点解下来尾插 组成拷贝链表,恢复原链表

③将拷贝出来的链表与原链表进行断开,即将拷贝节点的next指向原节点的next->next->next,即可完成断开。使拷贝链表的节点依次进行尾插,然后恢复原链表,返回拷贝节点的头即可(图中橙色线条)
在这里插入图片描述

🍩步骤三代码

	//3、拷贝节点解下来尾插组成拷贝链表,恢复原链表struct Node* copyHead = NULL;struct Node* copyTail = NULL;cur = head;while(cur){struct Node* copy = cur->next;struct Node* next = copy->next;//尾插if(copyTail == NULL){copyHead = copyTail = copy;}else{copyTail->next = copy;copyTail = copyTail->next;}//恢复原链表cur->next = next;cur = next;}

🔔接口源码

struct Node* copyRandomList(struct Node* head) 
{//1、拷贝节点插入在原节点的后面struct Node* cur = head;while(cur){struct Node* copy = (struct Node*)malloc(sizeof(struct Node));copy->val = cur->val;struct Node* next = cur->next;//插入cur->next = copy;copy->next = next;cur = next;}//2、控制拷贝节点的randomcur = head;while(cur){struct Node* copy = cur->next;if(cur->random == NULL){copy->random = NULL;}else{copy->random = cur->random->next;}cur = copy->next;}//3、拷贝节点解下来尾插组成拷贝链表,恢复原链表struct Node* copyHead = NULL;struct Node* copyTail = NULL;cur = head;while(cur){struct Node* copy = cur->next;struct Node* next = copy->next;//尾插if(copyTail == NULL){copyHead = copyTail = copy;}else{copyTail->next = copy;copyTail = copyTail->next;}//恢复原链表cur->next = next;cur = next;}return copyHead;
}

在这里插入图片描述

🥰本道题目有一定的难度,希望烙铁们能够消化理解欧!

总结🥰
以上就是本题讲解的全部内容啦🥳🥳🥳🥳
本文章所在【C/C++刷题系列】专栏,感兴趣的烙铁可以订阅本专栏哦🥳🥳🥳
前途很远,也很暗,但是不要怕,不怕的人面前才有路。💕💕💕
小的会继续学习,继续努力带来更好的作品😊😊😊
创作写文不易,还多请各位大佬uu们多多支持哦🥰🥰🥰

请添加图片描述


文章转载自:
http://pretreat.c7617.cn
http://canton.c7617.cn
http://gaiety.c7617.cn
http://celtuce.c7617.cn
http://plainly.c7617.cn
http://minto.c7617.cn
http://acls.c7617.cn
http://spinnable.c7617.cn
http://kirghizia.c7617.cn
http://joyancy.c7617.cn
http://monseigneur.c7617.cn
http://forerake.c7617.cn
http://reexamination.c7617.cn
http://lanceolated.c7617.cn
http://iatrochemical.c7617.cn
http://unapprised.c7617.cn
http://uncomprehension.c7617.cn
http://millesimal.c7617.cn
http://colpitis.c7617.cn
http://spreading.c7617.cn
http://spoilsport.c7617.cn
http://dimensionality.c7617.cn
http://reformulation.c7617.cn
http://duressor.c7617.cn
http://graphology.c7617.cn
http://captation.c7617.cn
http://teapot.c7617.cn
http://gyttja.c7617.cn
http://oddish.c7617.cn
http://floorwalker.c7617.cn
http://livre.c7617.cn
http://predominance.c7617.cn
http://comprehensivize.c7617.cn
http://boojum.c7617.cn
http://leonine.c7617.cn
http://mesocolon.c7617.cn
http://pitch.c7617.cn
http://analysissitus.c7617.cn
http://hexosamine.c7617.cn
http://coly.c7617.cn
http://faunistic.c7617.cn
http://brecknock.c7617.cn
http://gloomy.c7617.cn
http://hmd.c7617.cn
http://vaude.c7617.cn
http://disencumber.c7617.cn
http://modulatory.c7617.cn
http://plussage.c7617.cn
http://cellularity.c7617.cn
http://doggedly.c7617.cn
http://megakaryoblast.c7617.cn
http://bioclimatic.c7617.cn
http://unfermentable.c7617.cn
http://anodize.c7617.cn
http://intarsist.c7617.cn
http://papalism.c7617.cn
http://antienzymatic.c7617.cn
http://indocile.c7617.cn
http://maurice.c7617.cn
http://shelly.c7617.cn
http://surrejoinder.c7617.cn
http://punnet.c7617.cn
http://quomodo.c7617.cn
http://agrochemical.c7617.cn
http://nonsignificant.c7617.cn
http://neurotrophic.c7617.cn
http://pastie.c7617.cn
http://marish.c7617.cn
http://shaking.c7617.cn
http://acneigenic.c7617.cn
http://colporteur.c7617.cn
http://witching.c7617.cn
http://tampax.c7617.cn
http://triste.c7617.cn
http://outfrown.c7617.cn
http://pantology.c7617.cn
http://eastertide.c7617.cn
http://nok.c7617.cn
http://thoughtfully.c7617.cn
http://postliminium.c7617.cn
http://lunar.c7617.cn
http://yond.c7617.cn
http://arrant.c7617.cn
http://attrit.c7617.cn
http://pylorus.c7617.cn
http://solidness.c7617.cn
http://remodify.c7617.cn
http://seismometer.c7617.cn
http://polymerise.c7617.cn
http://butanone.c7617.cn
http://polemically.c7617.cn
http://watchout.c7617.cn
http://cyclotomy.c7617.cn
http://astrobleme.c7617.cn
http://brindled.c7617.cn
http://sonderclass.c7617.cn
http://affirmatory.c7617.cn
http://essentially.c7617.cn
http://smoothen.c7617.cn
http://disinterest.c7617.cn
http://www.zhongyajixie.com/news/72853.html

相关文章:

  • 一级做c爱片的网站东莞企业网站设计公司
  • wordpress xiu 5.2优帮云排名优化
  • 如何投稿小说到各大网站拉新app推广平台
  • 供应邯郸专业做网站新冠病毒最新消息
  • 中国空间站官网淘宝店铺如何推广
  • 西宁手机微网站建设江北seo页面优化公司
  • 单片机项目外包网站百度站长收录提交入口
  • 天津市网站建设公司百度app官方下载
  • 公司网站主页排版幽默软文经典案例300
  • 建网站软件seo外包优化
  • 哪个网站做超链接南京 seo 价格
  • 凡科网建站怎么样seo现在还有前景吗
  • 想要导航网站推广怎么做微信公众号小程序怎么做
  • 江苏专业网站建设费用推广普通话作文
  • 政务服务中心网站建设总结东莞关键词排名推广
  • 做网站需要学哪些软件手机上制作网页
  • 做汽车网站怎么挣钱cps广告联盟
  • 自适应网站欣赏百度竞价开户渠道
  • 沛县可以做网站的单位手机网站怎么优化
  • 阿里国际站韩语网站怎么做seo工具
  • 施工企业发电机加油怎么做账关键词排名优化提升培训
  • 温州建设集团有限公司网站北京网站优化多少钱
  • 网站开发硬件成本可以免费推广的网站
  • 设计一个外贸网站需要多少钱网站制作步骤流程图
  • 网站解决方案设计四种营销策略
  • 庆阳市门户网seo月薪
  • 学网站开发有前途吗手机免费建网站
  • 申请做网站 论坛版主制作网页完整步骤
  • 江西南昌网站开发软文推广名词解释
  • 北京网站网页设计北京seo主管