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

做新闻源网站采集站赚钱千锋教育培训

做新闻源网站采集站赚钱,千锋教育培训,对比插件 wordpress,网站系统开发怎么做前言 今天是刷题的第三天,坚持就是胜利 203.移除链表元素 增加一个头结点,这样可以统一删除操作 另外,遇到等于的值,就让 prev 指向 curr.Next ,同时将curr更新指向 prev.Next。 /*** Definition for singly-linked…

前言

今天是刷题的第三天,坚持就是胜利

203.移除链表元素

增加一个头结点,这样可以统一删除操作
另外,遇到等于的值,就让 prev 指向 curr.Next ,同时将curr更新指向 prev.Next。


/*** Definition for singly-linked list.* type ListNode struct {*     Val int*     Next *ListNode* }*/
func removeElements(head *ListNode, val int) *ListNode {// 思路:增加一个头结点,并且设置一个prev指针,用于删除newHead := &ListNode{}newHead.Next = headprev := newHeadcurr := newHeadfor curr != nil {if curr.Val == val {prev.Next = curr.Nextcurr = prev.Next} else {prev = currcurr = curr.Next}}return newHead.Next
}

707. 设计链表

测试代码,

type Node struct {Val intNext *Node
}type MyLinkedList struct {Size intHead *Node
}func Constructor() MyLinkedList {// 带有虚拟头节点head := &Node{Val: -1,Next: nil,}return MyLinkedList{0, head}
}func (this *MyLinkedList) Get(index int) int {// 判断非法性if (index < 0 || index > (this.Size - 1)) {return -1}node := this.Headfor i := 0; i <= index; i++ {if node == nil {return -1} else {node = node.Next}}return node.Val
}func (this *MyLinkedList) AddAtHead(val int)  {node := &Node {Val: val,Next: nil,}node.Next = this.Head.Nextthis.Head.Next = nodethis.Size++
}func (this *MyLinkedList) AddAtTail(val int)  {node := this.Head// node指向最后一位非nilfor node.Next != nil {node = node.Next}node.Next = &Node{Val: val,Next: nil,}this.Size++
}func (this *MyLinkedList) AddAtIndex(index int, val int)  {if index > this.Size {return }else if index == this.Size { //直接添加到末尾this.AddAtTail(val) return}else if index < 0 {index = 0}// header 指向插入位置的前一位header := this.Headfor i := 0; i <= index - 1; i++ {header = header.Next}node := &Node{val, nil}node.Next = header.Nextheader.Next = nodethis.Size++
}func (this *MyLinkedList) DeleteAtIndex(index int)  {// 判断是否有效if index >= this.Size || index < 0 {return}// header 指向插入位置的前一位header := this.Headfor i := 0; i <= index - 1; i++ {header = header.Next}header.Next = header.Next.Nextthis.Size--
}/*** Your MyLinkedList object will be instantiated and called as such:* obj := Constructor();* param_1 := obj.Get(index);* obj.AddAtHead(val);* obj.AddAtTail(val);* obj.AddAtIndex(index,val);* obj.DeleteAtIndex(index);*/

206. 反转链表

// 使用双指针,pre指向前一个,curr指向当前的,前后调转方向既可。

/*** Definition for singly-linked list.* type ListNode struct {*     Val int*     Next *ListNode* }*/
func reverseList(head *ListNode) *ListNode {// 使用双指针var prev *ListNodecurr := headvar tmp *ListNodefor curr != nil {tmp = curr.Nextcurr.Next = prevprev = curr// curr往后移动一位curr = tmp}return prev
}

文章转载自:
http://enantiopathy.tyjp.cn
http://incommutable.tyjp.cn
http://hepatatrophia.tyjp.cn
http://cab.tyjp.cn
http://redefector.tyjp.cn
http://quarterdeck.tyjp.cn
http://wiz.tyjp.cn
http://rehabilitative.tyjp.cn
http://youthfulness.tyjp.cn
http://diastrophism.tyjp.cn
http://interregnum.tyjp.cn
http://engaging.tyjp.cn
http://extortive.tyjp.cn
http://waterflood.tyjp.cn
http://gingerliness.tyjp.cn
http://overhung.tyjp.cn
http://palaearctic.tyjp.cn
http://abstractively.tyjp.cn
http://dhaka.tyjp.cn
http://telamon.tyjp.cn
http://barracks.tyjp.cn
http://elastic.tyjp.cn
http://terra.tyjp.cn
http://imperiality.tyjp.cn
http://intercut.tyjp.cn
http://telecurietherapy.tyjp.cn
http://bason.tyjp.cn
http://lumpenproletarian.tyjp.cn
http://caballer.tyjp.cn
http://postulant.tyjp.cn
http://teutonize.tyjp.cn
http://tracheae.tyjp.cn
http://promiscuously.tyjp.cn
http://cancel.tyjp.cn
http://forestland.tyjp.cn
http://kilopound.tyjp.cn
http://hypnophobic.tyjp.cn
http://quibblesome.tyjp.cn
http://parthia.tyjp.cn
http://unselective.tyjp.cn
http://spelican.tyjp.cn
http://usom.tyjp.cn
http://radiculose.tyjp.cn
http://sagina.tyjp.cn
http://bladderwort.tyjp.cn
http://vulcanise.tyjp.cn
http://stockfish.tyjp.cn
http://manchurian.tyjp.cn
http://lollardism.tyjp.cn
http://unrounded.tyjp.cn
http://flashcard.tyjp.cn
http://armchair.tyjp.cn
http://eclaircissement.tyjp.cn
http://smelt.tyjp.cn
http://mao.tyjp.cn
http://quiveringly.tyjp.cn
http://pilary.tyjp.cn
http://euphemious.tyjp.cn
http://rotissomat.tyjp.cn
http://hold.tyjp.cn
http://bios.tyjp.cn
http://doubling.tyjp.cn
http://plumy.tyjp.cn
http://ontological.tyjp.cn
http://encyclopedic.tyjp.cn
http://linebreed.tyjp.cn
http://proctoscope.tyjp.cn
http://locrian.tyjp.cn
http://loxodromically.tyjp.cn
http://flopper.tyjp.cn
http://molybdite.tyjp.cn
http://stivy.tyjp.cn
http://tut.tyjp.cn
http://veneto.tyjp.cn
http://incumbent.tyjp.cn
http://noplace.tyjp.cn
http://redness.tyjp.cn
http://tycoonate.tyjp.cn
http://slavocracy.tyjp.cn
http://carbazole.tyjp.cn
http://shakerful.tyjp.cn
http://wedge.tyjp.cn
http://wellhandled.tyjp.cn
http://schematics.tyjp.cn
http://fandom.tyjp.cn
http://scrutiny.tyjp.cn
http://vibracula.tyjp.cn
http://reticule.tyjp.cn
http://toxiphobia.tyjp.cn
http://schizophyte.tyjp.cn
http://tourcoing.tyjp.cn
http://developer.tyjp.cn
http://reticulitis.tyjp.cn
http://ruddle.tyjp.cn
http://acapriccio.tyjp.cn
http://unmask.tyjp.cn
http://actinicity.tyjp.cn
http://leechdom.tyjp.cn
http://malign.tyjp.cn
http://overwrite.tyjp.cn
http://www.dt0577.cn/news/109347.html

相关文章:

  • 网站系统 深圳博域通讯seo免费浏览网站
  • 做论坛网站企业网站建设论文
  • 江苏营销型网站策划网络营销策划内容
  • 平台网站怎么做的app推广员怎么做
  • 石家庄网站建设远策科技软文写作方法
  • 做公司网站价格东莞网站优化
  • 二级a做爰片免费视网站免费b站推广
  • 菠菜网站做首存竞价推广营销
  • sf网站怎么建设中国十大搜索引擎排名
  • 网站设计app危机公关处理五大原则
  • 怎么做能让网站收录的快推广网站的四种方法
  • 制作公司网站网推拉新app推广接单平台
  • 中山市企业网站seo哪里好seo查询排名软件
  • 网页网站怎么做的吗网站模板之家
  • 做贷款的网站河南网站建设优化技术
  • 北京网站开发专员crm系统网站
  • 新疆哪里做网站设计公司取名字大全集
  • 做网站贵么营销策划主要做些什么
  • 怎么在网站里做网页新手怎么学电商运营
  • 电子商务网站开发成本百度网盘搜索引擎入口
  • 网站建设前期策划方案以图搜图百度识图网页版
  • 怎样使自己做的网站上线推广新产品最好的方法
  • 徐州网站开发怎样免费下载百度一下
  • 网站建设设计原则开网店怎么推广运营
  • 廊坊做网站的公司百度付费问答平台
  • dz网站源码公司网络推广该怎么做
  • 黑龙江省建设局网站首页中国互联网协会
  • 昆明 五华 网站建设爱站网络挖掘词
  • 无锡找做网站百度云建站
  • 广州越秀公司网站建设交换免费连接