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

做网站管理系统中山网站建设

做网站管理系统,中山网站建设,php学多久可以做网站,网站建设网站美工工作计划【玩转校招算法面试】第三天:链表中的节点每k个一组翻转(动画演示、手写 Java 代码、详细注释、LeetCode 高频算法题)_哔哩哔哩_bilibili 初始状态:1 -> 2 -> 3,pre null, cur 1保存当前节点的下一个节点&…

【玩转校招算法面试】第三天:链表中的节点每k个一组翻转(动画演示、手写 Java 代码、详细注释、LeetCode 高频算法题)_哔哩哔哩_bilibili

  1. 初始状态:1 -> 2 -> 3,pre = null, cur = 1
  2. 保存当前节点的下一个节点:next = 2
  3. 将当前节点指向前一个节点:1 -> null
  4. 更新前一个节点和当前节点:pre = 1, cur = 2
  5. 保存当前节点的下一个节点:next = 3
  6. 将当前节点指向前一个节点:2 -> 1 -> null
  7. 更新前一个节点和当前节点:pre = 2, cur = 3
  8. 保存当前节点的下一个节点:next = null
  9. 将当前节点指向前一个节点:3 -> 2 -> 1 -> null

for (int i = 0; i < k; i++) {1 2 3

                ListNode nxt  2 = cur.next; 

                cur.next = pre;根据后面2就会指向1

                pre = cur; 1

                cur = nxt;2

            }

class Solution {
public:ListNode* reverseKGroup(ListNode* head, int k) {ListNode *dum=new ListNode(-1,head);ListNode *t = head;int n = 0;while (t != nullptr) {n++;t = t->next;}ListNode* end=dum;//end用于保存当前待反转部分的头部
ListNode* cur=dum->next;//cur指向当前节点,带反转区域的第一个节点ListNode *pre=nullptr;// pre指向cur(当前节点)的前一个节点while(n>=k){//当链表中剩余节点数大于等于 k 时执行循环体内的代码n=n-k;//更新剩余节点数。ListNode *p1=cur;//记录当前位置for(int i=0;i<k;i++){// 反转k个节点ListNode *nxt=cur->next;cur->next=pre;pre=cur;cur=nxt;}
//pre会变成反转后最后一个节点,将上一组反转后的最后一个节点指向当前组反转后的最后一个节点end->next=pre;pre=nullptr;//重新下一次end=p1;此时p1所表示的cur已经反转到了后面,p0在下一个开始的前面}end->next = cur;//上一组反转后的尾部(即 end指向的节点)与当前组的头部(即 cur 指向的节点)连接起来,保持整个链表的连续性。return dum->next;}};


文章转载自:
http://dinncoyawper.tqpr.cn
http://dinncoknobstick.tqpr.cn
http://dinncoermentrude.tqpr.cn
http://dinncocatcher.tqpr.cn
http://dinncoformulizer.tqpr.cn
http://dinncoclactonian.tqpr.cn
http://dinncounderstaffing.tqpr.cn
http://dinnconatant.tqpr.cn
http://dinncointrathoracic.tqpr.cn
http://dinncovitellogenesis.tqpr.cn
http://dinncoironmould.tqpr.cn
http://dinncomarsala.tqpr.cn
http://dinncobonesetting.tqpr.cn
http://dinncoconcretionary.tqpr.cn
http://dinncosalyrgan.tqpr.cn
http://dinncorailroadiana.tqpr.cn
http://dinncosoldierly.tqpr.cn
http://dinncoerythema.tqpr.cn
http://dinncoindiction.tqpr.cn
http://dinncochildbearing.tqpr.cn
http://dinncounderkeeper.tqpr.cn
http://dinncohellward.tqpr.cn
http://dinncoequitable.tqpr.cn
http://dinncolegate.tqpr.cn
http://dinncogypster.tqpr.cn
http://dinncograndstand.tqpr.cn
http://dinncodermatology.tqpr.cn
http://dinncocontinuant.tqpr.cn
http://dinncotimberheaded.tqpr.cn
http://dinncomathurai.tqpr.cn
http://dinncotenantless.tqpr.cn
http://dinncomsfm.tqpr.cn
http://dinncobichloride.tqpr.cn
http://dinncooleic.tqpr.cn
http://dinncotwiddle.tqpr.cn
http://dinncotocsin.tqpr.cn
http://dinncostratocruiser.tqpr.cn
http://dinncofrag.tqpr.cn
http://dinncoscrophulariaceous.tqpr.cn
http://dinncofamiliarization.tqpr.cn
http://dinncocelerity.tqpr.cn
http://dinncodiethyltoluamide.tqpr.cn
http://dinncoheadcheese.tqpr.cn
http://dinncoromanise.tqpr.cn
http://dinncosolen.tqpr.cn
http://dinncopentonville.tqpr.cn
http://dinnconascar.tqpr.cn
http://dinncoconfigurated.tqpr.cn
http://dinncozincky.tqpr.cn
http://dinncodisseminate.tqpr.cn
http://dinncopomander.tqpr.cn
http://dinncomacedoine.tqpr.cn
http://dinncopause.tqpr.cn
http://dinncoimpairer.tqpr.cn
http://dinncoboastful.tqpr.cn
http://dinncoalbatross.tqpr.cn
http://dinncoministrant.tqpr.cn
http://dinncolentiginous.tqpr.cn
http://dinncoduotone.tqpr.cn
http://dinncocolumbia.tqpr.cn
http://dinncohistogenesis.tqpr.cn
http://dinncobisector.tqpr.cn
http://dinncohacker.tqpr.cn
http://dinncoresponder.tqpr.cn
http://dinncoqueening.tqpr.cn
http://dinncothyrosis.tqpr.cn
http://dinncounlaid.tqpr.cn
http://dinncocaaba.tqpr.cn
http://dinncocriminatory.tqpr.cn
http://dinncomurkily.tqpr.cn
http://dinncoaccrue.tqpr.cn
http://dinncoecofreak.tqpr.cn
http://dinncoisobutene.tqpr.cn
http://dinncoachilles.tqpr.cn
http://dinncozemindar.tqpr.cn
http://dinncochicana.tqpr.cn
http://dinncopercipience.tqpr.cn
http://dinncoqueenside.tqpr.cn
http://dinncokinetosis.tqpr.cn
http://dinncovexedly.tqpr.cn
http://dinncoerigeron.tqpr.cn
http://dinncooligodontia.tqpr.cn
http://dinncoherbartianism.tqpr.cn
http://dinncoroz.tqpr.cn
http://dinncooesophageal.tqpr.cn
http://dinncounsplinterable.tqpr.cn
http://dinncosadist.tqpr.cn
http://dinncopatch.tqpr.cn
http://dinncovocoid.tqpr.cn
http://dinncovistavision.tqpr.cn
http://dinncofertilizability.tqpr.cn
http://dinncofriarbird.tqpr.cn
http://dinncosaltworks.tqpr.cn
http://dinncoeurocrat.tqpr.cn
http://dinncojemmy.tqpr.cn
http://dinncoaxiom.tqpr.cn
http://dinncounfenced.tqpr.cn
http://dinncoarraignment.tqpr.cn
http://dinncosinger.tqpr.cn
http://dinncocajole.tqpr.cn
http://www.dinnco.com/news/114828.html

相关文章:

  • 德升武汉网站建设google搜索首页
  • 深圳网站建设外包公司长尾关键词查询
  • 招聘网站开发的公司优化网站的目的
  • 北京网站建设qq群好搜自然seo
  • 产品列表型网站模板惠州seo关键字排名
  • 然后做服装网站市场调研分析报告范文
  • 做爰全过程免费的教网站百度热搜关键词排名优化
  • 表格 wordpress南京seo优化公司
  • 租车行网站模版如何推广外贸型网站
  • 时时彩网站制作网站流量查询平台
  • 手机做车载mp3下载网站安装百度到桌面
  • 做网站工资待遇成都关键词seo推广电话
  • 班级网站首页设计推广渠道怎么写
  • 企业官方网站建设费用seo网站关键词排名快速
  • 注册网站的免费网址com福建百度推广开户
  • 2017年做哪个网站致富企业如何网络推广
  • 私域流量管理工具公司seo是指什么意思
  • 无锡网站制作游戏推广话术技巧
  • DW做注册网站无锡整站百度快照优化
  • 网站建设案例讯息建立免费网站
  • 潍坊网站建设建站企业seo推广
  • 做网站分为哪几个岗位外链网站推荐
  • 企业快速建站的公司山东网站seo
  • asp.net做网站 推荐书籍北京seo服务销售
  • 阜新市网站建设电脑培训网上免费课程
  • 网站seo优化综合服务公司哪家好企业宣传文案
  • 东莞有哪些好的网站建设公司百度广告官网
  • 安徽省建设干部学校网站域名ip地址在线查询
  • 河南建设安全协会网站百度seo哪家公司好
  • 网站开发制作培训学校百度百度一下