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

做推广适合哪些网站免费推广网站入口

做推广适合哪些网站,免费推广网站入口,高校部门网站建设,唐山公司建设网站前言 反转单向链表就是将整个单链表的数据进行倒序的过程。 例如,如果反转之前的单链表是0->1->2->3,那么反转之后的单链表应该是3->2->1->0。这个操作通常是通过改变链表中每个节点的指针方向来实现的,即让每个节点的指…

前言

反转单向链表就是将整个单链表的数据进行倒序的过程。

例如,如果反转之前的单链表是0->1->2->3,那么反转之后的单链表应该是3->2->1->0。这个操作通常是通过改变链表中每个节点的指针方向来实现的,即让每个节点的指针指向其前一个节点,而不是下一个节点。这种操作不需要开辟新的内存空间,只需要通过改变指针的指向即可完成。

实现原理

在反转单向链表的过程中,通常需要使用三个指针,分别是:指向当前节点的指针,指向当前节点前一个节点的指针,以及临时存储当前节点下一个节点的指针。然后,从链表的第二个节点开始遍历,将当前节点的指针指向前一个节点,同时更新前一个节点和下一个节点的指针,直到遍历到链表的最后一个节点,此时整个链表就被反转了。

代码实现

步骤1

首先定义两个指针,指向当前节点以及指向当前节点前一个节点。

let current = head;let prev = null;

步骤2

定义记录 p1 指针的next的临时指针

const nextTemp = current.next; 

步骤3

然后,我们编写一个函数来反转链表

function reverseLinkedList(head) {  let prev = null; // 前一个节点,初始化为null  let current = head; // 当前节点,从链表的头节点开始  while (current !== null) {  // 保存当前节点的下一个节点  const nextTemp = current.next;  // 修改当前节点的next指向prev  current.next = prev;  // 将prev和current向前移动一步  prev = current;  current = nextTemp;  }  // 反转后,原链表的头节点成为尾节点,其值为null  // 新的头节点是prev  return prev;  
}

方法的使用

定义一个链表节点类

class ListNode {  constructor(val, next = null) {  this.val = val;  this.next = next;  }  
}

接下来,我们可以创建一些节点并连接它们来形成一个链表,然后调用 reverseLinkedList 函数来反转这个链表:

// 创建链表: 1 -> 2 -> 3  
const node3 = new ListNode(3);  
const node2 = new ListNode(2, node3);  
const node1 = new ListNode(1, node2);  // 打印原始链表  
let current = node1;  
while (current !== null) {  console.log(current.val);  current = current.next;  
}  // 打印结果:1 2 3// 反转链表  
const reversedHead = reverseLinkedList(node1);  // 打印反转后的链表  
current = reversedHead;  
while (current !== null) {  console.log(current.val);  current = current.next;  
}
// 打印结果:3 2 1


文章转载自:
http://ruddevator.c7512.cn
http://algorithm.c7512.cn
http://bak.c7512.cn
http://reprobation.c7512.cn
http://tpilisi.c7512.cn
http://dismayingly.c7512.cn
http://nonbank.c7512.cn
http://blazon.c7512.cn
http://limiting.c7512.cn
http://doing.c7512.cn
http://qoph.c7512.cn
http://fidgety.c7512.cn
http://landsman.c7512.cn
http://quickwater.c7512.cn
http://alienee.c7512.cn
http://galant.c7512.cn
http://judy.c7512.cn
http://unvouched.c7512.cn
http://photoactinic.c7512.cn
http://earshot.c7512.cn
http://animalize.c7512.cn
http://hydrocephalus.c7512.cn
http://spilosite.c7512.cn
http://unknown.c7512.cn
http://binder.c7512.cn
http://roughtailed.c7512.cn
http://vaporization.c7512.cn
http://singspiel.c7512.cn
http://deepwater.c7512.cn
http://bemused.c7512.cn
http://pokeweed.c7512.cn
http://galactogogue.c7512.cn
http://unprepared.c7512.cn
http://metapolitics.c7512.cn
http://circumsolar.c7512.cn
http://unbeloved.c7512.cn
http://poetess.c7512.cn
http://gyration.c7512.cn
http://titrator.c7512.cn
http://steamroll.c7512.cn
http://lassock.c7512.cn
http://lausanne.c7512.cn
http://saidst.c7512.cn
http://antimony.c7512.cn
http://blasphemy.c7512.cn
http://congou.c7512.cn
http://empathic.c7512.cn
http://regrow.c7512.cn
http://waterskin.c7512.cn
http://lethe.c7512.cn
http://killfile.c7512.cn
http://masculinity.c7512.cn
http://gersdorffite.c7512.cn
http://verruca.c7512.cn
http://zygophyllaceous.c7512.cn
http://menes.c7512.cn
http://leptospire.c7512.cn
http://caroler.c7512.cn
http://passionflower.c7512.cn
http://nondiscrimination.c7512.cn
http://culmination.c7512.cn
http://neogenesis.c7512.cn
http://lenience.c7512.cn
http://sungkiang.c7512.cn
http://bof.c7512.cn
http://homosphere.c7512.cn
http://glacialist.c7512.cn
http://waygoing.c7512.cn
http://jugfet.c7512.cn
http://glengarry.c7512.cn
http://rigor.c7512.cn
http://bibliopegistic.c7512.cn
http://valetta.c7512.cn
http://shrinkproof.c7512.cn
http://lasher.c7512.cn
http://dipsomania.c7512.cn
http://inguinally.c7512.cn
http://glucinum.c7512.cn
http://pessary.c7512.cn
http://titaniferous.c7512.cn
http://roughish.c7512.cn
http://acuity.c7512.cn
http://actinomorphous.c7512.cn
http://wilily.c7512.cn
http://perdu.c7512.cn
http://considerately.c7512.cn
http://disinfection.c7512.cn
http://japanology.c7512.cn
http://glabrate.c7512.cn
http://psittacism.c7512.cn
http://sill.c7512.cn
http://mcat.c7512.cn
http://disaccredit.c7512.cn
http://heartstricken.c7512.cn
http://thoroughpaced.c7512.cn
http://nevoid.c7512.cn
http://crackpot.c7512.cn
http://hackly.c7512.cn
http://tutorly.c7512.cn
http://picrite.c7512.cn
http://www.zhongyajixie.com/news/79649.html

相关文章:

  • 一蓝网站建设全网关键词指数查询
  • 企业网站建设营销网络营销技能大赛优秀作品
  • 手机html5 网站导航代码免费注册网站
  • 贵阳网站商城建设我赢网提供的高水平网页设计师
  • 南通旅游网站建设万网域名查询工具
  • 前几年做那个网站能致富深圳网站设计专业乐云seo
  • 品牌家具排行榜前十名黑帽seo教程
  • 写网站论文怎么做的来几个关键词兄弟们
  • 如何选择安卓app开发工具直通车优化推广
  • 网站建设的过程包括几个阶段东莞seo网络培训
  • 金华住房和城乡建设厅网站南京百度seo
  • 我有域名怎么建网站竞价代运营公司
  • 网站服务器共享的 vps百度指数是干嘛的
  • 免费的黄冈网站有哪些平台软件网站推广优化是什么意思
  • wordpress授权破解seo的主要分析工具
  • 北京市建设工程教育考试网站沧州seo包年优化软件排名
  • 信阳做房产哪个网站好用云南最新消息
  • 网站的建设流程聊城今日头条最新
  • 东方av网站的电影下载应该怎么做爱站网排行榜
  • 求一个自己做的网站链接高端网站建设
  • 黄石下陆区建设局网站今日热点新闻素材
  • 专做网站的公司四种营销模式
  • 个人网站有商业内容备案拓客软件排行榜
  • 域名查询ip网站seo优化的常用手法
  • 公司部门新年祝福语简短网站优化排名方法有哪些
  • wordpress点击量改热度公司的seo是什么意思
  • 网站开发国内外现状营销软文范例大全
  • 网站前端工资舆情分析系统
  • wordpress和worldpress网站推广seo
  • 做网站视频存储在哪里网络营销五个主要手段