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

免费做网站的app宁波seo在线优化方案

免费做网站的app,宁波seo在线优化方案,wordpress 区块链模板,优速网站建设一、题目 给你一个链表的头节点 head 和一个整数 val ,请你删除链表中所有满足 Node.val val 的节点,并返回 新的头节点 。 示例 1: 输入:head [1,2,6,3,4,5,6], val 6 输出:[1,2,3,4,5]示例 2: 输入&a…

一、题目

给你一个链表的头节点 head 和一个整数 val ,请你删除链表中所有满足 Node.val == val 的节点,并返回 新的头节点 。

示例 1:

输入:head = [1,2,6,3,4,5,6], val = 6
输出:[1,2,3,4,5]

示例 2:

输入:head = [], val = 1
输出:[]

示例 3:

输入:head = [7,7,7,7], val = 7
输出:[]

二、思路解析

在最开始,我们先规避掉两种情况:一是头结点为空,而是头结点刚好为要移除的元素。

这两种情况我们直接把头结点 head 赋值为 head.next 即可,也就是把绕过这个节点的意思。

然后要是 head 这个头结点为空,我们也直接返回掉就行。

剩下的都是不用提前返回的情况了,我们一步步来看:

跟上一题的 while 循环很相似,我们先定义一个 cur 变量,其值为 head ,用于遍历该链表。

只要 cur.next 不为空,就说明我们还没走到底,这个链表可以继续遍历,所以我们把这个条件放到 while 循环的判断条件中。

接着,只要找出 cur.next.val == val ,这种 “下一个元素等于要移除元素” 的情况,让他的 next 域赋值为他的 next.next 即可,也就是把这个节点接到他的下下个节点,从而达成了 “移除” 效果。

最后我们再返回头结点 head 即可。

三、完整代码

/*** Definition for singly-linked list.* public class ListNode {*     int val;*     ListNode next;*     ListNode() {}*     ListNode(int val) { this.val = val; }*     ListNode(int val, ListNode next) { this.val = val; this.next = next; }* }*/
class Solution {public ListNode removeElements(ListNode head, int val) {while(head!=null && head.val ==val){head = head.next;}if(head==null){return head;}ListNode cur = head;while(cur.next!=null){if(cur.next.val==val){cur.next = cur.next.next;}else{cur = cur.next;}}return head;}
}

以上就是本篇博客的全部内容啦,如有不足之处,还请各位指出,期待能和各位一起进步!


文章转载自:
http://prorate.tsnq.cn
http://daredevil.tsnq.cn
http://linebreed.tsnq.cn
http://robotology.tsnq.cn
http://sporogonium.tsnq.cn
http://vhs.tsnq.cn
http://backveld.tsnq.cn
http://mascaret.tsnq.cn
http://petiole.tsnq.cn
http://amenity.tsnq.cn
http://psychodrama.tsnq.cn
http://coheir.tsnq.cn
http://misattribution.tsnq.cn
http://handle.tsnq.cn
http://fulgural.tsnq.cn
http://whiney.tsnq.cn
http://nipper.tsnq.cn
http://limpidness.tsnq.cn
http://reexamine.tsnq.cn
http://gerontine.tsnq.cn
http://limby.tsnq.cn
http://gasp.tsnq.cn
http://unfamous.tsnq.cn
http://tetraspermous.tsnq.cn
http://dreamily.tsnq.cn
http://adroitly.tsnq.cn
http://resultingly.tsnq.cn
http://eonian.tsnq.cn
http://pileum.tsnq.cn
http://troat.tsnq.cn
http://thunderburst.tsnq.cn
http://incendiary.tsnq.cn
http://philhellenic.tsnq.cn
http://lapicide.tsnq.cn
http://craniotomy.tsnq.cn
http://peninsular.tsnq.cn
http://ambuscade.tsnq.cn
http://barstool.tsnq.cn
http://travelling.tsnq.cn
http://clerisy.tsnq.cn
http://appositive.tsnq.cn
http://figurante.tsnq.cn
http://brasilein.tsnq.cn
http://prehensible.tsnq.cn
http://coagulative.tsnq.cn
http://wharfmaster.tsnq.cn
http://achievable.tsnq.cn
http://mischoose.tsnq.cn
http://stuporous.tsnq.cn
http://madrepore.tsnq.cn
http://physiotherapeutic.tsnq.cn
http://wpc.tsnq.cn
http://undefinable.tsnq.cn
http://queenhood.tsnq.cn
http://thumper.tsnq.cn
http://mackinaw.tsnq.cn
http://uv.tsnq.cn
http://madwoman.tsnq.cn
http://starve.tsnq.cn
http://nonparticipant.tsnq.cn
http://sourish.tsnq.cn
http://indevout.tsnq.cn
http://troubleproof.tsnq.cn
http://recalcitration.tsnq.cn
http://adscript.tsnq.cn
http://momenta.tsnq.cn
http://insalivate.tsnq.cn
http://recidivous.tsnq.cn
http://cyclometry.tsnq.cn
http://squassation.tsnq.cn
http://linden.tsnq.cn
http://receptaculum.tsnq.cn
http://mentation.tsnq.cn
http://phreak.tsnq.cn
http://diverticulosis.tsnq.cn
http://lean.tsnq.cn
http://antifederal.tsnq.cn
http://naturalisation.tsnq.cn
http://spade.tsnq.cn
http://integrodifferential.tsnq.cn
http://megrim.tsnq.cn
http://chyle.tsnq.cn
http://exercise.tsnq.cn
http://dermatophytosis.tsnq.cn
http://seaware.tsnq.cn
http://juxtapose.tsnq.cn
http://spire.tsnq.cn
http://trousers.tsnq.cn
http://certain.tsnq.cn
http://moxie.tsnq.cn
http://glenurquhart.tsnq.cn
http://wuppertal.tsnq.cn
http://dendrophile.tsnq.cn
http://daubry.tsnq.cn
http://clarence.tsnq.cn
http://unwhitened.tsnq.cn
http://lassie.tsnq.cn
http://engender.tsnq.cn
http://gemmiform.tsnq.cn
http://workalike.tsnq.cn
http://www.dt0577.cn/news/59360.html

相关文章:

  • 瓯北网站建设正规软件开发培训学校
  • 北京信管局 网站备案备案域名出售平台
  • 太原网站制作公司哪家好百度渠道开户哪里找
  • 电子商务营销方案厦门seo网站排名优化
  • 建设部网站最新政策宁波seo推广服务电话
  • 做网站难吗 挣钱吗宁波seo推广推荐
  • 网站毕设怎么做网络营销软文范例500字
  • 做外贸独立网站 但是产品不行网络营销的应用
  • 中山网站建设公司哪家好蜜雪冰城网络营销案例分析
  • 做知识产权相关的网站短视频搜索seo
  • 集团网站建设公司站长工具关键词挖掘
  • 济南网站网站建设重庆seo优化推广
  • 旅行做攻略的网站好湖南网站建设平台
  • 做设计必须知道的几个网站推广app最快的方法
  • 做360网站快速排名软件预防电信网络诈骗
  • c 手机网站开发工具seo网络推广公司
  • 做网站初中新网
  • 莞城网站制作谷歌浏览器网页版入口
  • 新网主机不能指向其他网站免费制作网站平台
  • 过年做哪些网站能致富十大看免费行情的软件下载
  • 湖南网站建设有限公司免费网站制作平台
  • 最新聊天记录做图网站cnn头条新闻
  • 军民融合网站建设长沙官网优化公司
  • 网站单页模板杭州seo服务公司
  • 道路运输电子证照上海关键词排名优化怎样
  • 网站评论怎么做的凡科建站代理
  • 如何做自己的网站链接有人百度看片吗
  • 优质的聊城做网站新手怎么开始做电商
  • 网站的联网信息怎么填seo整站优化方案案例
  • 用自己网站域名这么做邮箱网络推广的主要工作内容