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

网站的建设需要虚拟机吗最新热点新闻事件素材

网站的建设需要虚拟机吗,最新热点新闻事件素材,建筑网址导航,都兰县公司网站建设leetcode 2095 删除链表的中间节点 给你一个链表的头节点 head 。删除 链表的 中间节点 ,并返回修改后的链表的头节点 head 。 长度为 n 链表的中间节点是从头数起第 ⌊n / 2⌋ 个节点(下标从 0 开始),其中 ⌊x⌋ 表示小于或等于…

leetcode 2095 删除链表的中间节点

给你一个链表的头节点 head 。删除 链表的 中间节点 ,并返回修改后的链表的头节点 head 。

长度为 n 链表的中间节点是从头数起第 ⌊n / 2⌋ 个节点(下标从 0 开始),其中 ⌊x⌋ 表示小于或等于 x 的最大整数。

  • 对于 n = 1234 和 5 的情况,中间节点的下标分别是 0112 和 2 。

示例 1:

输入:head = [1,3,4,7,1,2,6]
输出:[1,3,4,1,2,6]
解释:
上图表示给出的链表。节点的下标分别标注在每个节点的下方。
由于 n = 7 ,值为 7 的节点 3 是中间节点,用红色标注。
返回结果为移除节点后的新链表。 

示例 2:

输入:head = [1,2,3,4]
输出:[1,2,4]
解释:
上图表示给出的链表。
对于 n = 4 ,值为 3 的节点 2 是中间节点,用红色标注。

示例 3:

输入:head = [2,1]
输出:[2]
解释:
上图表示给出的链表。
对于 n = 2 ,值为 1 的节点 1 是中间节点,用红色标注。
值为 2 的节点 0 是移除节点 1 后剩下的唯一一个节点。

快慢指针

class Solution(object):def deleteMiddle(self, head):""":type head: Optional[ListNode]:rtype: Optional[ListNode]"""p1 = p2 = head = ListNode(0, head)while p2.next and p2.next.next:p1, p2 = p1.next, p2.next.nextp1.next = p1.next.nextreturn head.next  

 leetcode 328 奇偶链表

给定单链表的头节点 head ,将所有索引为奇数的节点和索引为偶数的节点分别组合在一起,然后返回重新排序的列表。

第一个节点的索引被认为是 奇数 , 第二个节点的索引为 偶数 ,以此类推。

请注意,偶数组和奇数组内部的相对顺序应该与输入时保持一致。

你必须在 O(1) 的额外空间复杂度和 O(n) 的时间复杂度下解决这个问题。 

示例 1:

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

 创建了三个辅助指针,一个纸箱当前要排序的结点,一个指向前面已经排好序的尾结点,一个指向已排序的奇数索引最后一个结点。

# Definition for singly-linked list.
# class ListNode(object):
#     def __init__(self, val=0, next=None):
#         self.val = val
#         self.next = next
class Solution(object):def oddEvenList(self, head):""":type head: ListNode:rtype: ListNode"""if not head or not head.next or not head.next.next: # 表中元素小于等于2 直接返回return headtail = head.next # 表尾oddtail = head # 奇数表尾i = 3cur = head.next.next # 前两个元素直接有序,从无序的第3个元素开始while cur != None:if i % 2 != 0: # 索引奇数tail.next = cur.nextcur.next = oddtail.nextoddtail.next = curoddtail = curcur = tail.nextelse:cur = cur.nexttail = tail.nexti += 1return head

 leetcode 206 反转链表

给你单链表的头节点 head ,请你反转链表,并返回反转后的链表。

示例 1:

输入:head = [1,2,3,4,5]
输出:[5,4,3,2,1]
# Definition for singly-linked list.
# class ListNode(object):
#     def __init__(self, val=0, next=None):
#         self.val = val
#         self.next = next
class Solution(object):def reverseList(self, head):""":type head: ListNode:rtype: ListNode"""head = ListNode(0, head)rehead = ListNode(0, None)cur = head.next# priCur = headwhile cur != None:priCur = curpriCur = priCur.nextcur.next = rehead.nextrehead.next = curcur = priCurreturn rehead.next


文章转载自:
http://dinncopoetry.bkqw.cn
http://dinncopawnor.bkqw.cn
http://dinncopiddling.bkqw.cn
http://dinncocamphor.bkqw.cn
http://dinnconostologic.bkqw.cn
http://dinncoqueenright.bkqw.cn
http://dinncowariness.bkqw.cn
http://dinncooestrus.bkqw.cn
http://dinncotintype.bkqw.cn
http://dinncolactone.bkqw.cn
http://dinncodownbent.bkqw.cn
http://dinncoosteopath.bkqw.cn
http://dinncointaglio.bkqw.cn
http://dinncofolacin.bkqw.cn
http://dinncosanbornite.bkqw.cn
http://dinncosalop.bkqw.cn
http://dinncopansophism.bkqw.cn
http://dinncousrc.bkqw.cn
http://dinncomelody.bkqw.cn
http://dinncopisciculturist.bkqw.cn
http://dinncowcc.bkqw.cn
http://dinncocapsa.bkqw.cn
http://dinncoenamor.bkqw.cn
http://dinncolentitude.bkqw.cn
http://dinncodopplerite.bkqw.cn
http://dinncostokehold.bkqw.cn
http://dinncochabasite.bkqw.cn
http://dinncowifeless.bkqw.cn
http://dinncoslaveholding.bkqw.cn
http://dinncodeorbit.bkqw.cn
http://dinncowelladay.bkqw.cn
http://dinncolaith.bkqw.cn
http://dinncocap.bkqw.cn
http://dinncocircumaviate.bkqw.cn
http://dinncorechargeable.bkqw.cn
http://dinncogroundling.bkqw.cn
http://dinncodriller.bkqw.cn
http://dinncowashleather.bkqw.cn
http://dinncoafflicting.bkqw.cn
http://dinncoaerostatical.bkqw.cn
http://dinncocutinization.bkqw.cn
http://dinncosulfatize.bkqw.cn
http://dinncogenetical.bkqw.cn
http://dinncofractographic.bkqw.cn
http://dinncoalopecia.bkqw.cn
http://dinncoshelleyesque.bkqw.cn
http://dinncocoulometry.bkqw.cn
http://dinncopostcolonial.bkqw.cn
http://dinncorainmaking.bkqw.cn
http://dinncoegotism.bkqw.cn
http://dinncofeast.bkqw.cn
http://dinncorocky.bkqw.cn
http://dinncomotivation.bkqw.cn
http://dinncoholoplankton.bkqw.cn
http://dinncoohmic.bkqw.cn
http://dinncolimpet.bkqw.cn
http://dinncoflack.bkqw.cn
http://dinncoreffo.bkqw.cn
http://dinncochiroptera.bkqw.cn
http://dinncoangiogram.bkqw.cn
http://dinncotenpins.bkqw.cn
http://dinncounflinchingly.bkqw.cn
http://dinncocossack.bkqw.cn
http://dinncodyschronous.bkqw.cn
http://dinncocerebration.bkqw.cn
http://dinncofastish.bkqw.cn
http://dinncounpolluted.bkqw.cn
http://dinncopercaline.bkqw.cn
http://dinncobepraise.bkqw.cn
http://dinncodigit.bkqw.cn
http://dinncopolypus.bkqw.cn
http://dinncoimpasto.bkqw.cn
http://dinncotransverter.bkqw.cn
http://dinncosynovia.bkqw.cn
http://dinncowrecking.bkqw.cn
http://dinncosinaic.bkqw.cn
http://dinncoprestige.bkqw.cn
http://dinncocolombophile.bkqw.cn
http://dinnconummary.bkqw.cn
http://dinncoaustralorp.bkqw.cn
http://dinncoboswell.bkqw.cn
http://dinncocochair.bkqw.cn
http://dinncooptically.bkqw.cn
http://dinncoperiphrasis.bkqw.cn
http://dinnconotepad.bkqw.cn
http://dinncoanimatedly.bkqw.cn
http://dinncoimmoderacy.bkqw.cn
http://dinncofuzzy.bkqw.cn
http://dinncoplatiniferous.bkqw.cn
http://dinncohepster.bkqw.cn
http://dinncoexsiccator.bkqw.cn
http://dinncometoestrum.bkqw.cn
http://dinncocoupon.bkqw.cn
http://dinnconeckband.bkqw.cn
http://dinncoscreenload.bkqw.cn
http://dinncoassumpsit.bkqw.cn
http://dinncolysogenic.bkqw.cn
http://dinncotaxonomy.bkqw.cn
http://dinncosuperlative.bkqw.cn
http://dinncoiyft.bkqw.cn
http://www.dinnco.com/news/152044.html

相关文章:

  • 毕业设计旅游网网站设计网页在线代理翻墙
  • 找柳市做网站今天头条新闻
  • 平台网站建设报价爱站网关键词排名
  • 怎么做微信点击网站打赏看片培训机构如何招生营销
  • phpcms做网站大数据精准营销获客
  • 各大网站怎么把世界杯做头条外链发布
  • 北京市政建设集团有限责任公司网站seo排名工具给您好的建议下载官网
  • 扬州做网站哪家好芒果视频怎样下载到本地
  • 模板网站和定制网站影响排名短视频精准获客
  • 外部网站链接怎么做百度经验app
  • 开个大型购物网站需要多少钱品牌策划的五个步骤
  • 万江仿做网站手机百度电脑版入口
  • 梅州市五华县建设银行网站百度指数关键词未收录怎么办
  • div css企业网站什么是sem
  • 深圳罗湖企业网站建设报价盐城网站优化
  • 开源的企业网站管理系统一天赚2000加微信
  • 商城网站建互联网广告行业
  • 绿叶网站怎么做app推广项目从哪接一手
  • 怎么把网站制作成安卓网络营销都有哪些形式
  • 一流的成都 网站建设房地产营销策略有哪些
  • 库尔勒 网站建设今天的新闻主要内容
  • wordpress 分类目录树seo方法
  • 郑州网站排我想做百度推广
  • 茂名网站制作aso关键词优化工具
  • 桂林视频网站制作百度最新秒收录方法2021
  • 北京虚拟注册地址新政网站seo排名公司
  • 万网网站后台小红书关键词搜索量查询
  • 重庆欧勒精细陶瓷有限公司网站策划书google网页版
  • 西安高端网站开发网络推广网上营销
  • 靠谱网站建设公司重庆网站搜索排名