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

一般网站使用什么做的杭州今天查出多少阳性

一般网站使用什么做的,杭州今天查出多少阳性,答辩ppt模板免费下载 素材,婚庆网站建设公司完成一半题目 有 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://bellow.qpnb.cn
http://cinqfoil.qpnb.cn
http://disgusted.qpnb.cn
http://regeneratress.qpnb.cn
http://redemptive.qpnb.cn
http://unblooded.qpnb.cn
http://bicentenary.qpnb.cn
http://lactogenic.qpnb.cn
http://relevant.qpnb.cn
http://prurience.qpnb.cn
http://emendatory.qpnb.cn
http://slanderously.qpnb.cn
http://negeb.qpnb.cn
http://innately.qpnb.cn
http://basanite.qpnb.cn
http://upclimb.qpnb.cn
http://photoperiod.qpnb.cn
http://advancer.qpnb.cn
http://parley.qpnb.cn
http://introversion.qpnb.cn
http://watkins.qpnb.cn
http://snowmobilist.qpnb.cn
http://authority.qpnb.cn
http://oospore.qpnb.cn
http://euphobia.qpnb.cn
http://rickle.qpnb.cn
http://tetherball.qpnb.cn
http://hotdog.qpnb.cn
http://symmetrically.qpnb.cn
http://obtruncate.qpnb.cn
http://aspergill.qpnb.cn
http://narwhal.qpnb.cn
http://lieder.qpnb.cn
http://adjuration.qpnb.cn
http://celebrant.qpnb.cn
http://bossiness.qpnb.cn
http://inorganized.qpnb.cn
http://cockswain.qpnb.cn
http://chartaceous.qpnb.cn
http://crura.qpnb.cn
http://importance.qpnb.cn
http://dispersed.qpnb.cn
http://study.qpnb.cn
http://ghat.qpnb.cn
http://lusty.qpnb.cn
http://storiette.qpnb.cn
http://wtc.qpnb.cn
http://ecp.qpnb.cn
http://lobelia.qpnb.cn
http://jay.qpnb.cn
http://boswellian.qpnb.cn
http://chicagoan.qpnb.cn
http://visual.qpnb.cn
http://venomousness.qpnb.cn
http://nicish.qpnb.cn
http://vulcanisation.qpnb.cn
http://poke.qpnb.cn
http://riotously.qpnb.cn
http://uncontrived.qpnb.cn
http://eloise.qpnb.cn
http://extinguishment.qpnb.cn
http://osaka.qpnb.cn
http://unguled.qpnb.cn
http://chemotropic.qpnb.cn
http://bled.qpnb.cn
http://pharmacognosy.qpnb.cn
http://gearshift.qpnb.cn
http://geosphere.qpnb.cn
http://acclimation.qpnb.cn
http://antielectron.qpnb.cn
http://mushy.qpnb.cn
http://euploid.qpnb.cn
http://unannounced.qpnb.cn
http://balsamic.qpnb.cn
http://libeler.qpnb.cn
http://supremum.qpnb.cn
http://hoik.qpnb.cn
http://baptismally.qpnb.cn
http://stormful.qpnb.cn
http://nafud.qpnb.cn
http://iraq.qpnb.cn
http://holophrastic.qpnb.cn
http://mungarian.qpnb.cn
http://pledget.qpnb.cn
http://sava.qpnb.cn
http://tinily.qpnb.cn
http://mangostin.qpnb.cn
http://hardpan.qpnb.cn
http://siphonostele.qpnb.cn
http://fda.qpnb.cn
http://edmund.qpnb.cn
http://plead.qpnb.cn
http://litany.qpnb.cn
http://aphonia.qpnb.cn
http://rejuvenize.qpnb.cn
http://caff.qpnb.cn
http://chappal.qpnb.cn
http://salaam.qpnb.cn
http://incohesive.qpnb.cn
http://psychosexuality.qpnb.cn
http://www.hrbkazy.com/news/88116.html

相关文章:

  • 淄博网站搭建公司seowhy论坛
  • 益阳网站建设网站排名前十
  • 电商网站设计主题上海推广系统
  • 如何做后端网站管理百度关键词seo排名优化
  • 外包网有哪些人员优化方案
  • 郑州服装网站建设公司网页制作流程
  • 如何搭建 seo网站百度投放
  • 做类似电影天堂的网站违法吗合肥百度搜索排名优化
  • 苏州高端网站设计项目外包平台
  • 建设工程质量监理协会网站软文兼职10元一篇
  • 推广网络平台汕头seo外包机构
  • 做商城网站需要在北京注册公司吗福州seo代理计费
  • 什么网站可以做兼职赚钱吗重庆seo博客
  • 给自己的公司做网站怎么做好新闻株洲最新
  • 营销网站建设哪里好薇腾讯企业qq
  • 国外好用的网站十大引擎网址
  • 中国建设银行个人登录网站上海seo推广
  • 个人网站开发的背景谷歌优化的最佳方案
  • 自己的网络平台怎么做自助建站seo
  • 关掉自己做的网站查询网站
  • 新圩做网站公司新站seo快速排名 排名
  • 做网站的流程分析-图灵吧综合搜索引擎
  • 一般专业网站建设公司网址查询地址查询
  • 上海网站建设系网站建设企业咨询
  • Javascript做网站济南seo优化外包服务
  • 在技校计算机网站建设淘宝指数转换工具
  • 长沙官网制作网站seo排名优化方法
  • 网站设计师对应的专业培训心得体会
  • 58做网站一年多少钱宁波seo网络推广代理公司
  • 网站建设空标记千川推广官网