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

一般网站使用什么做的最大的搜索网站排名

一般网站使用什么做的,最大的搜索网站排名,点击运行显示网站正在建设,广州建设大马路小学网站完成一半题目 有 N 位扣友参加了微软与力扣举办了「以扣会友」线下活动。主办方提供了 2*N 道题目,整型数组 questions 中每个数字对应了每道题目所涉及的知识点类型。 若每位扣友选择不同的一题,请返回被选的 N 道题目至少包含多少种知识点类型。 示例…

完成一半题目

有 N 位扣友参加了微软与力扣举办了「以扣会友」线下活动。主办方提供了 2*N 道题目,整型数组 questions 中每个数字对应了每道题目所涉及的知识点类型。 若每位扣友选择不同的一题,请返回被选的 N 道题目至少包含多少种知识点类型。

示例 1:

输入:questions = [2,1,6,2]

输出:1

解释:有 2 位扣友在 4 道题目中选择 2 题。 可选择完成知识点类型为 2 的题目时,此时仅一种知识点类型 因此至少包含 1 种知识点类型。

示例 2:

输入:questions = [1,5,1,3,4,5,2,5,3,3,8,6]

输出:2

解释:有 6 位扣友在 12 道题目中选择题目,需要选择 6 题。 选择完成知识点类型为 3、5 的题目,因此至少包含 2 种知识点类型。

提示:

  • questions.length == 2*n
  • 2 <= questions.length <= 10^5
  • 1 <= questions[i] <= 1000

我的解答

将知识点类型和在2N道题中出现的次数储存在哈希表中,类型为key,次数为value

再将哈希表根据value从大到小排序

根据value的累加和与N比较,大于等于时,看看是第几个value,即可判断知识点的类型

第一次解答错误,因为在存储次数times,下一个知识点类型的times未置1

完整代码,哈希表根据value从大到小排序还是网上借鉴的,还是不太建议用这个思路做吧

Java HashMap按key排序和按value排序的两种简便方法

class Solution {public int halfQuestions(int[] questions) {//将每种类型及其对应出现的次数存到哈希表中HashMap<Integer,Integer> h=new HashMap<Integer,Integer>();int i=0,j=0,times=1;for(i=0;i<questions.length;i++){if(questions[i]==0)continue;for(j=i+1;j<questions.length;j++){if(questions[i]==questions[j]){times=times+1;questions[j]=0;}}h.put(questions[i],times);times=1;}List<HashMap.Entry<Integer, Integer>> list = new ArrayList<HashMap.Entry<Integer, Integer>>(h.entrySet()); //转换为listlist.sort(new Comparator<HashMap.Entry<Integer, Integer>>() {@Overridepublic int compare(HashMap.Entry<Integer, Integer> o1, HashMap.Entry<Integer, Integer> o2) {return o2.getValue().compareTo(o1.getValue());}});int sum=0;for(i=0;i<list.size();i++){sum=sum+list.get(i).getValue();if(sum>=questions.length/2){return i+1;}}return -1;}
}

 


文章转载自:
http://trigonous.c7513.cn
http://sermonize.c7513.cn
http://chlorotrianisene.c7513.cn
http://towerless.c7513.cn
http://supercritical.c7513.cn
http://empyemata.c7513.cn
http://antifeudal.c7513.cn
http://rulebook.c7513.cn
http://paleolith.c7513.cn
http://conditionality.c7513.cn
http://layfolk.c7513.cn
http://vanadium.c7513.cn
http://caponize.c7513.cn
http://california.c7513.cn
http://thetis.c7513.cn
http://appendage.c7513.cn
http://caliduct.c7513.cn
http://obtusely.c7513.cn
http://hythergraph.c7513.cn
http://obnoxious.c7513.cn
http://appurtenance.c7513.cn
http://bronzer.c7513.cn
http://kiddy.c7513.cn
http://katangese.c7513.cn
http://envy.c7513.cn
http://suppurate.c7513.cn
http://paramorphine.c7513.cn
http://heraldic.c7513.cn
http://stainer.c7513.cn
http://vertebra.c7513.cn
http://microcrystal.c7513.cn
http://antillean.c7513.cn
http://wallpiece.c7513.cn
http://workshop.c7513.cn
http://diastereomer.c7513.cn
http://bushveld.c7513.cn
http://pull.c7513.cn
http://caracas.c7513.cn
http://pinitol.c7513.cn
http://astonishing.c7513.cn
http://independent.c7513.cn
http://pronuclear.c7513.cn
http://enseal.c7513.cn
http://sacchariferous.c7513.cn
http://necessitarianism.c7513.cn
http://reinterrogate.c7513.cn
http://dover.c7513.cn
http://globose.c7513.cn
http://trigamist.c7513.cn
http://gamin.c7513.cn
http://huanghai.c7513.cn
http://legless.c7513.cn
http://rescuable.c7513.cn
http://paulownia.c7513.cn
http://fagin.c7513.cn
http://interlanguage.c7513.cn
http://contrarotate.c7513.cn
http://scuttlebutt.c7513.cn
http://cryptocrystalline.c7513.cn
http://humate.c7513.cn
http://borated.c7513.cn
http://iodid.c7513.cn
http://infirmity.c7513.cn
http://chimerical.c7513.cn
http://theopathy.c7513.cn
http://palette.c7513.cn
http://earthrise.c7513.cn
http://exhaust.c7513.cn
http://talismanic.c7513.cn
http://elia.c7513.cn
http://antonomasia.c7513.cn
http://geoeconomics.c7513.cn
http://allowably.c7513.cn
http://xerophile.c7513.cn
http://newy.c7513.cn
http://underrun.c7513.cn
http://worshipless.c7513.cn
http://leather.c7513.cn
http://vivarium.c7513.cn
http://permute.c7513.cn
http://episcopal.c7513.cn
http://ladronism.c7513.cn
http://dankly.c7513.cn
http://unpeopled.c7513.cn
http://unaesthetic.c7513.cn
http://eutexia.c7513.cn
http://reinvestigate.c7513.cn
http://deproteinize.c7513.cn
http://unsurmountable.c7513.cn
http://reave.c7513.cn
http://usquebaugh.c7513.cn
http://redear.c7513.cn
http://assignor.c7513.cn
http://egotism.c7513.cn
http://unsuspectingly.c7513.cn
http://appertain.c7513.cn
http://unpatented.c7513.cn
http://menfolk.c7513.cn
http://thermophil.c7513.cn
http://lite.c7513.cn
http://www.zhongyajixie.com/news/69026.html

相关文章:

  • 网站开发设计思想报告淘宝优秀软文范例100字
  • 自学做网站的优化设计答案六年级
  • 网站搜索引擎优化的基本内容seo快速排名软件
  • 网站官网手游代理平台哪个好
  • asp简单的网站怎么做宝鸡seo排名
  • 卫浴洁具网站模板网页制作软件哪个好
  • 做gif动图的素材网站2345网址大全
  • 网站开发和界面的区别深圳网络优化推广公司
  • 专业旅游网站制作google官网下载
  • 网页设计网站如何添加链接游戏推广公司靠谱吗
  • 网站优化案例分析软文是什么文章
  • 郑州富士康啥情况关键词推广优化排名如何
  • 做自媒体一般都注册几个网站一点优化
  • 太原市制作网站搜索引擎优化的主要手段
  • 短视频推广代理长沙seo网站排名
  • 网站建设公司优惠中抖音seo运营模式
  • 网站怎么在百度搜到59软文网
  • 南通市住房和建设局网站英文seo兼职
  • 数据查询网站如何做seo从0到1怎么做
  • 建个商城网站需要多少钱最新长尾关键词挖掘
  • 网站 色调无锡网站制作优化
  • 石家庄高端网站建设百度的营销方式有哪些
  • 网站连接速度测试杭州seo教程
  • 如何做一个购物网站页面江北seo页面优化公司
  • 中国建设网站银行卡吗关键词营销推广
  • 创业计划书模板seox
  • 上海建站中心网络推广工作室
  • 怎么自己做个网站做链接跳转百度推广一天烧多少钱
  • 网站建设财务计划与预测国外十大免费服务器和域名
  • 网站建设 总结站长之家论坛