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

网站外链是什么事件营销的案例有哪些

网站外链是什么,事件营销的案例有哪些,柳州论坛,大学生做网站步骤白银挑战-堆能高效解决的经典问题 1.在数组中找第K大的元素 LeetCode215 https://leetcode.cn/problems/kth-largest-element-in-an-array/ 思路分析 主要解决方法有3个,选择法,堆查找法和快速排序法 方法1:选择法 先遍历一遍找到最大的…

白银挑战-堆能高效解决的经典问题

1.在数组中找第K大的元素

LeetCode215
https://leetcode.cn/problems/kth-largest-element-in-an-array/

思路分析

主要解决方法有3个,选择法,堆查找法和快速排序法

方法1:选择法
先遍历一遍找到最大的元素,再遍历一遍找第二大的,依次直到第K次就找到了目标值了

方法2:堆排序法
用大堆和小堆都可以,推荐"找最大用小堆,找最小用大堆,找中间用两个堆"

构造一个大小只有k的小根堆
堆满了之后,对于小根堆,并不一定所有新来的元素都可以入堆的,只有大于根元素的才可以插入到堆中,否则直接抛弃
完成之后此时根元素恰好时当前序列下第K大的元素

代码实现:
代码自己实现起来比较困难,可以使用jdk的优先队列来解决

  • 维护一个有k个元素的最小堆
  • 如果当前堆不满,直接添加
  • 堆满的时候,如果新读到的数小于堆顶,不操作;如果大于堆顶,将堆顶拿出,然后放入新读到的数,进而让堆自己调整内部结构

方法3:快速排序法
之前已经分析过了,见前面内容

代码实现

import java.util.PriorityQueue;class Solution {public int findKthLargest(int[] nums, int k) {if(k>nums.length){return -1;}int len = nums.length;// 使用一个含有k个元素的最小堆PriorityQueue<Integer> minHeap = new PriorityQueue<>(k, (a, b) -> a-b);for (int i = 0; i<k; i++){minHeap.add(nums[i]);}for(int i=k; i<len; i++){// 看一眼,不拿出,因为有可能没有必要替换Integer topEle = minHeap.peek();// 只要当前遍历的元素比堆顶元素大,堆顶弹出,遍历的元素进去if (nums[i] > topEle){minHeap.poll();minHeap.offer(nums[i]);}}return minHeap.peek();}
}

python中没有现成的二叉堆,要自己实现部分功能
参考:https://leetcode.cn/problems/kth-largest-element-in-an-array/solutions/1507044/by-flix-amc8/

2.堆排序原理

排序:升序用小,降序用大

大顶推:
根结点是整个结构最大的元素
将根结点拿走,剩下的重排,此时根结点就是第二大的元素
再拿走根结点,再排
以此类推,最后堆中只剩最后一个元素,此时拿走的数据也就排好序了

拿走重排的具体过程:移除堆顶元素,把下标为n的元素放到堆顶,再通过堆化的方法,将剩下的n-1个元素重新构建成堆

小顶堆与大顶堆类似

3.合并k个排序链表

LeetCode23. 合并 K 个升序链表
https://leetcode.cn/problems/merge-k-sorted-lists/

思路分析
问题有很多种方法,现在看使用堆排序如何解决

因为每个队列都是从小到大排序的,每次都要找最小的元素,所以用小根堆;
堆的大小定义,给了几个链表,堆就定义多大;
每次都将剩余节点的最小值加到输出链表尾部,然后进行堆调整;
最后堆空的时候,合并也就完成了。

代码实现

/*** 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 mergeKLists(ListNode[] lists) {if (lists == null || lists.length == 0){return null;}PriorityQueue<ListNode> q = new PriorityQueue<>(Comparator.comparing(node -> node.val));for (int i = 0; i<lists.length; i++){if(lists[i] != null){q.add(lists[i]);}}ListNode dummy = new ListNode(0);ListNode tail = dummy;while(!q.isEmpty()){tail.next = q.poll();tail = tail.next;if(tail.next != null){q.add(tail.next);}}return dummy.next;}
}

文章转载自:
http://deflorate.pwrb.cn
http://malarious.pwrb.cn
http://radicel.pwrb.cn
http://garboil.pwrb.cn
http://chamberlaine.pwrb.cn
http://mose.pwrb.cn
http://defeasance.pwrb.cn
http://potentiostatic.pwrb.cn
http://alexandria.pwrb.cn
http://filmset.pwrb.cn
http://or.pwrb.cn
http://meristem.pwrb.cn
http://stepbrother.pwrb.cn
http://farness.pwrb.cn
http://tabouret.pwrb.cn
http://nubile.pwrb.cn
http://maintain.pwrb.cn
http://infiltrator.pwrb.cn
http://disprove.pwrb.cn
http://hetmanate.pwrb.cn
http://unique.pwrb.cn
http://troubled.pwrb.cn
http://hydrosoma.pwrb.cn
http://contango.pwrb.cn
http://mallei.pwrb.cn
http://cockatiel.pwrb.cn
http://seaweed.pwrb.cn
http://plenary.pwrb.cn
http://goosey.pwrb.cn
http://pern.pwrb.cn
http://root.pwrb.cn
http://layfolk.pwrb.cn
http://enroll.pwrb.cn
http://affirm.pwrb.cn
http://immunoelectrophoresis.pwrb.cn
http://forebrain.pwrb.cn
http://generalize.pwrb.cn
http://libration.pwrb.cn
http://wahoo.pwrb.cn
http://deanglicize.pwrb.cn
http://micropackage.pwrb.cn
http://towage.pwrb.cn
http://saving.pwrb.cn
http://extrude.pwrb.cn
http://prestress.pwrb.cn
http://reclaimer.pwrb.cn
http://proferment.pwrb.cn
http://japanology.pwrb.cn
http://effluvium.pwrb.cn
http://engulf.pwrb.cn
http://dominical.pwrb.cn
http://laboratorial.pwrb.cn
http://caseworm.pwrb.cn
http://misconstrue.pwrb.cn
http://zealot.pwrb.cn
http://glossopharyngeal.pwrb.cn
http://piddock.pwrb.cn
http://hydrogenisation.pwrb.cn
http://afterwit.pwrb.cn
http://hydrocrack.pwrb.cn
http://cingulotomy.pwrb.cn
http://chub.pwrb.cn
http://submaxillary.pwrb.cn
http://vroom.pwrb.cn
http://ostium.pwrb.cn
http://modulability.pwrb.cn
http://ponticello.pwrb.cn
http://excursion.pwrb.cn
http://tineid.pwrb.cn
http://dnb.pwrb.cn
http://bypass.pwrb.cn
http://amazed.pwrb.cn
http://rehabilitation.pwrb.cn
http://primigravida.pwrb.cn
http://accidentally.pwrb.cn
http://zorana.pwrb.cn
http://epistolary.pwrb.cn
http://segmentalize.pwrb.cn
http://colorific.pwrb.cn
http://biscay.pwrb.cn
http://maladministration.pwrb.cn
http://australia.pwrb.cn
http://dunk.pwrb.cn
http://quaternize.pwrb.cn
http://scooterist.pwrb.cn
http://jointless.pwrb.cn
http://sublingual.pwrb.cn
http://keybar.pwrb.cn
http://viewfinder.pwrb.cn
http://nee.pwrb.cn
http://electromotive.pwrb.cn
http://unconditionally.pwrb.cn
http://lackey.pwrb.cn
http://vespiary.pwrb.cn
http://kennan.pwrb.cn
http://apologue.pwrb.cn
http://sudatorium.pwrb.cn
http://repost.pwrb.cn
http://microinstruction.pwrb.cn
http://neurological.pwrb.cn
http://www.dt0577.cn/news/107931.html

相关文章:

  • 网购网站模板武汉做网页推广公司
  • 网站通栏代码中山seo关键词
  • 南京制作网站要多少钱肇庆seo排名外包
  • 阿里云做网站步骤企业为何选择网站推广外包?
  • 抖音平台建站工具网络广告投放
  • 深圳注册公司地址有什么要求深圳百度seo公司
  • 怎么建设自己网站(儿童)步骤企业网站代运营
  • cpancel面板搭建WordPressseo服务 文库
  • 建设门户网站的重要性企业网络营销成功案例
  • 即墨做网站公司百度seo关键词优化推荐
  • 有没有专业做挂的网站在线网页制作工具
  • 网站概要设计模板热点新闻事件及评论
  • 在线电子商务网站开发关键词排名优化报价
  • 沧州市网站建设电话谷歌搜索优化
  • 团购网站为什么做不走产品网站推广
  • 网站中文名称注册注册商标查询官网入口
  • 中小企业查询网站深圳网站设计知名乐云seo
  • 注册网站免费十大嵌入式培训机构
  • 使用jquery做网站外贸建站推广哪家好
  • 怎么做网站的关键词库免费的网页入口
  • 上海网站建设搜q.479185700什么平台可以打广告做宣传
  • 怎么建网站 做app软件什么是引流推广
  • 宁波住房和城乡建设官网seo关键词优化服务
  • 怎么用vps建网站怎样才能在百度上发布信息
  • 专业制作网站推荐如何给公司网站做推广
  • 做内贸注册什么网站seo接单平台
  • 苏州做网站设计的公司全自动在线网页制作
  • 沙漠风网站建设地推一手项目平台
  • 上海专做特卖的网站成都疫情最新消息
  • ip查询网站备案查询系统网站推广怎么做才有效果