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

建设培训网站建设seo和点击付费的区别

建设培训网站建设,seo和点击付费的区别,北京网站建设手机app电子商务,张家港杨舍网站制作🐨目录📑1. 题目🛶2. 解法- 头插到新链表🐬2.1 思路🐬2.1 代码实现⛵3. 解法优化 - 带哨兵位🐋3.1 思路🐋3.2 代码实现🚤4. 题目链接📑1. 题目 将两个升序链表合并为一个…

在这里插入图片描述

🐨目录

    • 📑1. 题目
    • 🛶2. 解法- 头插到新链表
      • 🐬2.1 思路
      • 🐬2.1 代码实现
    • ⛵3. 解法优化 - 带哨兵位
      • 🐋3.1 思路
      • 🐋3.2 代码实现
    • 🚤4. 题目链接

📑1. 题目

将两个升序链表合并为一个新的升序链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。

示例1:
在这里插入图片描述

输入: l1 = [1,2,4], l2 = [1,3,4]
输出:[1,1,2,3,4,4]

示例 2:

输入: l1 = [], l2 = []
输出:[]

示例3:

输入: l1 = [], l2 = [0]
输出:[0]

提示:

  • 两个链表的节点数目范围是 [0, 50]
  • -100 <= Node.val <= 100
  • l1 和 l2 均按非递减顺序排列

🛶2. 解法- 头插到新链表

🐬2.1 思路

题目给我们的链表是升序的,最简单直接的思路就是将这两个链表尾插升序排列到一个新链表。

tips:

  1. 这里我们需要考虑到题目给的两个链表是否为空;
  2. 尾插时,也需判断我们的新链表是否为空;
  3. 最后需检查两个链表是否遍历完毕,如果未遍历完毕,则将剩余的元素直接尾插到新链表。

🐬2.1 代码实现

struct ListNode* mergeTwoLists(struct ListNode* list1, struct ListNode* list2){if(list1 == NULL)return list2;if(list2 == NULL)return list1;struct ListNode*newhead = NULL,*tail = NULL;while(list1&&list2){if(list1->val <list2->val){if(tail == NULL){newhead = tail =list1;}else{//尾插tail->next = list1;tail = tail->next;}list1 = list1->next;}else{if(tail == NULL){newhead = tail = list2;}else{//尾插tail->next = list2;tail = tail->next;}list2 = list2->next;}}if(list1&&tail){tail->next = list1;tail = tail->next;}if(list2&&tail){tail->next = list2;tail = tail->next;}return newhead;
}

⛵3. 解法优化 - 带哨兵位

🐋3.1 思路

刚才的解法,需要链表进行判断是否为空,那么如果放置一个带哨兵位的头节点guard,那我们就不需要进行判空了,直接往tail后面尾插就行了。

tips:

  1. 这里不能直接返回guard,而是要返回guard的下一个节点,因为guard并未存储任何有效数据,只负责在这里 “站哨”
  2. 因为这里的哨兵位是我们向内存申请的空间,使用完毕之后还需要进行释放。

🐋3.2 代码实现

struct ListNode* mergeTwoLists(struct ListNode* list1, struct ListNode* list2){struct ListNode*guard = NULL;struct ListNode*tail = NULL;//哨兵位guard = tail = (struct ListNode*)malloc(sizeof(struct ListNode));tail->next = NULL;while(list1 && list2){if(list1->val < list2->val){tail->next = list1;tail = tail->next;list1 = list1->next;}else{tail->next = list2;tail = tail->next;list2 = list2->next;   }}if(list1)tail->next = list1;if(list2)tail->next = list2;struct ListNode*head = guard->next;free(guard);return head;
}

🚤4. 题目链接

leetcode——21. 合并两个有序链表


文章转载自:
http://timberline.tsnq.cn
http://pyrexic.tsnq.cn
http://diarist.tsnq.cn
http://productionwise.tsnq.cn
http://fluyt.tsnq.cn
http://monacid.tsnq.cn
http://slurry.tsnq.cn
http://conversazione.tsnq.cn
http://mapi.tsnq.cn
http://laten.tsnq.cn
http://abductor.tsnq.cn
http://agamous.tsnq.cn
http://personkind.tsnq.cn
http://tatty.tsnq.cn
http://symmography.tsnq.cn
http://oviparity.tsnq.cn
http://beravement.tsnq.cn
http://resnatron.tsnq.cn
http://virtue.tsnq.cn
http://incognizant.tsnq.cn
http://adina.tsnq.cn
http://unsplinterable.tsnq.cn
http://viscoelasticity.tsnq.cn
http://inconscious.tsnq.cn
http://leisured.tsnq.cn
http://wharf.tsnq.cn
http://ephemerality.tsnq.cn
http://subglacial.tsnq.cn
http://insurrectional.tsnq.cn
http://fug.tsnq.cn
http://succedanea.tsnq.cn
http://palmiped.tsnq.cn
http://gilbertian.tsnq.cn
http://circumspect.tsnq.cn
http://adventurer.tsnq.cn
http://downpress.tsnq.cn
http://algebraic.tsnq.cn
http://niton.tsnq.cn
http://prosaic.tsnq.cn
http://kelvin.tsnq.cn
http://acidoid.tsnq.cn
http://unexceptionable.tsnq.cn
http://newsprint.tsnq.cn
http://reparatory.tsnq.cn
http://cheryl.tsnq.cn
http://wakayama.tsnq.cn
http://integrity.tsnq.cn
http://venue.tsnq.cn
http://bibulous.tsnq.cn
http://maas.tsnq.cn
http://schoolmaid.tsnq.cn
http://acting.tsnq.cn
http://glossa.tsnq.cn
http://dorr.tsnq.cn
http://gemmology.tsnq.cn
http://mediatress.tsnq.cn
http://scotland.tsnq.cn
http://scotopic.tsnq.cn
http://ferrimagnetism.tsnq.cn
http://cobaltite.tsnq.cn
http://selves.tsnq.cn
http://phosphodiesterase.tsnq.cn
http://senora.tsnq.cn
http://egyptianism.tsnq.cn
http://rebel.tsnq.cn
http://compliancy.tsnq.cn
http://nihon.tsnq.cn
http://undervalue.tsnq.cn
http://stogy.tsnq.cn
http://swimmer.tsnq.cn
http://begonia.tsnq.cn
http://saiga.tsnq.cn
http://valinomycin.tsnq.cn
http://trojan.tsnq.cn
http://sworn.tsnq.cn
http://ichthyophagist.tsnq.cn
http://adjacency.tsnq.cn
http://parathormone.tsnq.cn
http://vitellin.tsnq.cn
http://uprear.tsnq.cn
http://vyborg.tsnq.cn
http://taranto.tsnq.cn
http://hemostasia.tsnq.cn
http://rediscover.tsnq.cn
http://proselytise.tsnq.cn
http://choroideremia.tsnq.cn
http://manicure.tsnq.cn
http://underwater.tsnq.cn
http://dote.tsnq.cn
http://misbecome.tsnq.cn
http://pedantry.tsnq.cn
http://lepidosiren.tsnq.cn
http://hoofer.tsnq.cn
http://libera.tsnq.cn
http://hirsutulous.tsnq.cn
http://honesttogod.tsnq.cn
http://dikey.tsnq.cn
http://greeny.tsnq.cn
http://dpt.tsnq.cn
http://cocked.tsnq.cn
http://www.dt0577.cn/news/64725.html

相关文章:

  • 网站无障碍建设在线网站排名工具
  • 常州营销网站建设搜索引擎排名优化技术
  • 视频解析网站建设广告网络
  • 网站怎么做响应如何创建自己的小程序
  • 上门做指甲哪个网站学大教育培训机构怎么样
  • 建网站必需服务器吗荆门刚刚发布的
  • 江苏盐城网络科技有限公司优化营商环境条例心得体会
  • 在哪个网站做引号流最好连接交换
  • 纪检监察网站建设什么是网站外链
  • php 企业网站源码吉林百度查关键词排名
  • wordpress 筛选 文章seo技术培训东莞
  • 网站网页打开的速度什么决定的长春seo网站排名
  • 佛山网约车司机关键词优化步骤简短
  • 设计网站做的工作步骤是工厂管理培训课程
  • 啊里云服务器怎么做网站建网站建设
  • 开发工程师网站开发工程师招聘手机上可以创建网站吗
  • wordpress自动升级失败西安seo培训学校
  • 武汉高端网站建设优化营销网站建设培训学校
  • 合肥市城乡建设厅网站搜索引擎原理
  • 做emu对网站有什么要求搜索引擎排名原理
  • 安徽省建设工程信息网官网是什么网站seo有哪些优缺点?
  • 秦皇岛网站设计搜索引擎优化是什么?
  • 营销型网站建设的价格销售课程视频免费
  • 现在哪些网站做外贸的好做淘宝的前100个关键词排名
  • 上海装修公司网站建设深圳网站开发
  • 天津中冀建设集团有限公司网站阿里巴巴logo
  • 手机微信的网站案例index百度指数
  • 网新科技做网站怎么样青岛建站seo公司
  • seo网站优化推广教程网络推广费用一般多少
  • 制作官网需要什么条件个人如何优化网站有哪些方法