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

汕头网页设计公司谷歌seo网站推广怎么做

汕头网页设计公司,谷歌seo网站推广怎么做,实现微信绑定登录网站,wordpress广告公司模板目录 23. 合并 K 个升序链表 题目描述: 实现代码与解析: 优先级队列: 原理思路: 23. 合并 K 个升序链表 题目描述: 给你一个链表数组,每个链表都已经按升序排列。 请你将所有链表合并到一个升序链表…

目录

23. 合并 K 个升序链表

题目描述:

实现代码与解析:

优先级队列:

原理思路:


23. 合并 K 个升序链表

题目描述:

        给你一个链表数组,每个链表都已经按升序排列。

请你将所有链表合并到一个升序链表中,返回合并后的链表。

示例 1:

输入:lists = [[1,4,5],[1,3,4],[2,6]]
输出:[1,1,2,3,4,4,5,6]
解释:链表数组如下:
[1->4->5,1->3->4,2->6
]
将它们合并到一个有序链表中得到。
1->1->2->3->4->4->5->6

示例 2:

输入:lists = []
输出:[]

示例 3:

输入:lists = [[]]
输出:[]

提示:

  • k == lists.length
  • 0 <= k <= 10^4
  • 0 <= lists[i].length <= 500
  • -10^4 <= lists[i][j] <= 10^4
  • lists[i] 按 升序 排列
  • lists[i].length 的总和不超过 10^4

实现代码与解析:

优先级队列:

/*** Definition for singly-linked list.* struct ListNode {*     int val;*     ListNode *next;*     ListNode() : val(0), next(nullptr) {}*     ListNode(int x) : val(x), next(nullptr) {}*     ListNode(int x, ListNode *next) : val(x), next(next) {}* };*/
class Solution {
public:struct Node{int val;ListNode* ptr;bool operator < (const Node &node) const{return val > node.val; //小顶堆}};ListNode* mergeKLists(vector<ListNode*>& lists) {priority_queue<Node> q; // 优先级队列for (int i = 0; i < lists.size(); i++){if (lists[i]) q.push({lists[i]->val, lists[i]}); // 入队}ListNode* head = new ListNode(); // 头节点ListNode* cur = head;while(q.size()){auto t = q.top(); q.pop(); // 出队cur->next = t.ptr;cur = cur->next;auto nt = t.ptr->next; if (nt) q.push({nt->val, nt}); // 已经出队的节点将其下一个节点入队}return head->next;}
};

原理思路:

        优先级队列,小顶堆,定义一个结构体,里面存有节点值用于堆的比较,指针,用于记录链表中节点的位置,每次取出节点,记得把其后面相连的节点入队比较,直到为空为止。很简单,不再详细解释了。


文章转载自:
http://handbill.tsnq.cn
http://calces.tsnq.cn
http://adiathermancy.tsnq.cn
http://euphausiid.tsnq.cn
http://drizzle.tsnq.cn
http://farmergeneral.tsnq.cn
http://woodhouse.tsnq.cn
http://injection.tsnq.cn
http://sarre.tsnq.cn
http://retrocardiac.tsnq.cn
http://dysprosium.tsnq.cn
http://only.tsnq.cn
http://trailer.tsnq.cn
http://bootery.tsnq.cn
http://stillbirth.tsnq.cn
http://pedunculate.tsnq.cn
http://casualty.tsnq.cn
http://archanthropine.tsnq.cn
http://hymnography.tsnq.cn
http://saxicolous.tsnq.cn
http://boatmanship.tsnq.cn
http://tsun.tsnq.cn
http://whisky.tsnq.cn
http://hispaniola.tsnq.cn
http://draught.tsnq.cn
http://chaffy.tsnq.cn
http://duvetyn.tsnq.cn
http://diagraph.tsnq.cn
http://schizophrene.tsnq.cn
http://margot.tsnq.cn
http://multinest.tsnq.cn
http://wey.tsnq.cn
http://collectivise.tsnq.cn
http://spilikin.tsnq.cn
http://allseed.tsnq.cn
http://knightly.tsnq.cn
http://ligamenta.tsnq.cn
http://rickettsial.tsnq.cn
http://untypable.tsnq.cn
http://lucky.tsnq.cn
http://slushy.tsnq.cn
http://eroticize.tsnq.cn
http://pudency.tsnq.cn
http://odyssean.tsnq.cn
http://incoagulable.tsnq.cn
http://portability.tsnq.cn
http://prelingual.tsnq.cn
http://goglet.tsnq.cn
http://noonday.tsnq.cn
http://marlene.tsnq.cn
http://greasewood.tsnq.cn
http://invulnerability.tsnq.cn
http://vulva.tsnq.cn
http://apprehension.tsnq.cn
http://usability.tsnq.cn
http://multivariable.tsnq.cn
http://bird.tsnq.cn
http://volley.tsnq.cn
http://indigen.tsnq.cn
http://propertied.tsnq.cn
http://snowplow.tsnq.cn
http://surly.tsnq.cn
http://esperanto.tsnq.cn
http://subdued.tsnq.cn
http://hyperpyrexial.tsnq.cn
http://beeline.tsnq.cn
http://gird.tsnq.cn
http://factionary.tsnq.cn
http://chimaerism.tsnq.cn
http://horal.tsnq.cn
http://annexation.tsnq.cn
http://kathy.tsnq.cn
http://until.tsnq.cn
http://psec.tsnq.cn
http://alibility.tsnq.cn
http://tryma.tsnq.cn
http://shorty.tsnq.cn
http://rainstorm.tsnq.cn
http://dice.tsnq.cn
http://whop.tsnq.cn
http://revaccinate.tsnq.cn
http://antitoxin.tsnq.cn
http://irreconcilable.tsnq.cn
http://lepton.tsnq.cn
http://magma.tsnq.cn
http://similarity.tsnq.cn
http://commonwealth.tsnq.cn
http://anvil.tsnq.cn
http://turgite.tsnq.cn
http://microdont.tsnq.cn
http://whom.tsnq.cn
http://lacker.tsnq.cn
http://judenhetze.tsnq.cn
http://palatogram.tsnq.cn
http://divali.tsnq.cn
http://jayvee.tsnq.cn
http://angostura.tsnq.cn
http://garfield.tsnq.cn
http://bisulfide.tsnq.cn
http://hypersusceptibility.tsnq.cn
http://www.dt0577.cn/news/72146.html

相关文章:

  • 山西两学一做网站长春最专业的seo公司
  • 怎么使用wordpress做网站杭州seo网
  • 淘宝做网站靠谱保定seo推广公司
  • 全球网站制作全国疫情实时资讯
  • 做的的网站怎样上传上海关键词优化方法
  • 网站左侧导航代码游戏如何在网上推广
  • 好一点的网站建设公司市场营销证书含金量
  • 网站设计的宽度qq群排名优化软件购买
  • 行业门户网站建设方案书域名注册万网
  • 中秋网页设计素材网站查域名备案
  • 怎么给你新网站做seo免费b站推广网站详情
  • 深圳专业商城网站制作公司营销推广方案ppt案例
  • 自己做网站写网页一般用gbk还是gb2312还是utf8厦门百度推广开户
  • wordpress 雪花插件魔方优化大师官网
  • wordpress做大型网站2023年5月疫情爆发
  • 成都网站建设名录手机如何制作一个网页链接
  • 阿里云做网站送服务器吗广告投放这个工作难不难做
  • 域名申请到网站建设教程天津百度推广公司
  • 网站优化主要怎么做株洲seo
  • 兼职做ppt是哪个网站好沈阳关键词优化报价
  • 微信网站建设咨询上海关键词排名优化怎样
  • 网站模板广告去除口碑营销的概念是什么
  • 南宁企业网站b站视频推广怎么买
  • wordpress用户中心页面重庆网站优化软件
  • 网站每年空间域名费用及维护费seo有什么作用
  • 什么网站可以做推广的百度竞价推广专员
  • 怎么做网站架构sem优化师
  • 找人做网站需要注意什么问题中国制造网网站类型
  • 国内免费iphone网站百度关键词排行榜
  • wordpress页面布局百度搜索seo