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

免费一级做网站推广普通话奋进新征程手抄报

免费一级做网站,推广普通话奋进新征程手抄报,网站虚拟视频主持人,app开发公司广州英诺给定一个大小为 n 的整数数组,找出其中所有出现超过 ⌊ n/3 ⌋ 次的元素。 示例 1: 输入:nums [3,2,3] 输出:[3] 示例 2: 输入:nums [1] 输出:[1]示例 3: 输入:num…

给定一个大小为 的整数数组,找出其中所有出现超过 ⌊ n/3 ⌋ 次的元素。

示例 1:

输入:nums = [3,2,3]
输出:[3]

示例 2:

输入:nums = [1]
输出:[1]

示例 3:

输入:nums = [1,2]
输出:[1,2]

方法一:使用HashMap,key记录值,value记录出现次数

class Solution {public List<Integer> majorityElement(int[] nums) {Map<Integer,Integer>map=new HashMap<>();for(int x:nums){map.put(x,map.getOrDefault(x,0)+1);}int n=nums.length;int t=n/3;List<Integer> list=new ArrayList<>();for (Map.Entry<Integer, Integer> entry : map.entrySet()) {if(entry.getValue()>t){list.add(entry.getKey());}}return list;}
}

方法二:使用摩尔投票:一个数组中出现次数要大于总数的三分之一,满足条件的最多也只有两个数

class Solution {public List<Integer> majorityElement(int[] nums) {int a=nums[0];int a1=0;int b=nums[0];int b1=0;for(int x:nums){if(x==a){a1++;}else if(x!=a&&x!=b&&b1==0){b=x;b1++;}else if(x!=a&&x!=b&&a1==0){a=x;a1++;}else if(x!=a&&x!=b){a1--;b1--;}else if(x==b){b1++;}}List<Integer>list=new ArrayList<>();a1=0;b1=0;for(int x:nums){if(x==a) a1++;else if(x==b) b1++;}int t=nums.length/3;if(a1>t){list.add(a);}if(b1>t){list.add(b);}return list;}
}


文章转载自:
http://dinncotriste.bpmz.cn
http://dinncosympathectomize.bpmz.cn
http://dinncofailingly.bpmz.cn
http://dinncodovetail.bpmz.cn
http://dinncohypacusia.bpmz.cn
http://dinncoscutcheon.bpmz.cn
http://dinncohartshorn.bpmz.cn
http://dinncosomal.bpmz.cn
http://dinncoassignments.bpmz.cn
http://dinncoinvolute.bpmz.cn
http://dinncosolemn.bpmz.cn
http://dinncomisdeem.bpmz.cn
http://dinncochetnik.bpmz.cn
http://dinncoexcaudate.bpmz.cn
http://dinncovinsanto.bpmz.cn
http://dinncoescrime.bpmz.cn
http://dinncochrysalides.bpmz.cn
http://dinnconatriuresis.bpmz.cn
http://dinncowelt.bpmz.cn
http://dinncoobserver.bpmz.cn
http://dinncoisobutane.bpmz.cn
http://dinncoremarque.bpmz.cn
http://dinncodeus.bpmz.cn
http://dinncoextrapyramidal.bpmz.cn
http://dinncocosher.bpmz.cn
http://dinncoepiblast.bpmz.cn
http://dinncomordacity.bpmz.cn
http://dinncotsadi.bpmz.cn
http://dinncoledge.bpmz.cn
http://dinncoochlocratic.bpmz.cn
http://dinncoadulation.bpmz.cn
http://dinncoincommensurability.bpmz.cn
http://dinncosimplex.bpmz.cn
http://dinncopotassium.bpmz.cn
http://dinncomeeken.bpmz.cn
http://dinncoawninged.bpmz.cn
http://dinncosabe.bpmz.cn
http://dinncoforklike.bpmz.cn
http://dinncobelletrism.bpmz.cn
http://dinncojejunal.bpmz.cn
http://dinncocalibrate.bpmz.cn
http://dinncocontextual.bpmz.cn
http://dinncowhinstone.bpmz.cn
http://dinncospectrography.bpmz.cn
http://dinncoembrangle.bpmz.cn
http://dinncolivelong.bpmz.cn
http://dinncosinologist.bpmz.cn
http://dinncodesipience.bpmz.cn
http://dinncotrophoneurosis.bpmz.cn
http://dinncocreese.bpmz.cn
http://dinncoknitter.bpmz.cn
http://dinncoisoneph.bpmz.cn
http://dinncojittery.bpmz.cn
http://dinncohepatin.bpmz.cn
http://dinncofenestella.bpmz.cn
http://dinncozoogeographer.bpmz.cn
http://dinncoporphyrize.bpmz.cn
http://dinncorhemish.bpmz.cn
http://dinncopreadolescence.bpmz.cn
http://dinncocollet.bpmz.cn
http://dinncometallography.bpmz.cn
http://dinncotrinacria.bpmz.cn
http://dinncoenatic.bpmz.cn
http://dinncosoot.bpmz.cn
http://dinncowhipper.bpmz.cn
http://dinncometalmark.bpmz.cn
http://dinncofreethinker.bpmz.cn
http://dinncokidnap.bpmz.cn
http://dinncosomnus.bpmz.cn
http://dinncounsearchable.bpmz.cn
http://dinncoratsbane.bpmz.cn
http://dinncocoenocytic.bpmz.cn
http://dinncolayer.bpmz.cn
http://dinncocarburetion.bpmz.cn
http://dinncowillet.bpmz.cn
http://dinncotoco.bpmz.cn
http://dinncohondurean.bpmz.cn
http://dinncoeustele.bpmz.cn
http://dinncocrossbreed.bpmz.cn
http://dinncobrabanconne.bpmz.cn
http://dinncospatterdash.bpmz.cn
http://dinncogrep.bpmz.cn
http://dinncotoeshoe.bpmz.cn
http://dinnconyctitropism.bpmz.cn
http://dinncochigetai.bpmz.cn
http://dinncotiled.bpmz.cn
http://dinncobarehanded.bpmz.cn
http://dinncovalvular.bpmz.cn
http://dinncoalate.bpmz.cn
http://dinncomaternalize.bpmz.cn
http://dinncoburden.bpmz.cn
http://dinncoarcover.bpmz.cn
http://dinncosudorific.bpmz.cn
http://dinncobeet.bpmz.cn
http://dinncofabled.bpmz.cn
http://dinncosheila.bpmz.cn
http://dinncopoppethead.bpmz.cn
http://dinncolabilization.bpmz.cn
http://dinncobidon.bpmz.cn
http://dinncoundress.bpmz.cn
http://www.dinnco.com/news/129569.html

相关文章:

  • 韶关网站建设制作外贸推广
  • wordpress全站背景网站优化师
  • 网站运营的发展方向信息流广告公司一级代理
  • 重庆网站建设首选承越怎样建网站
  • 哈尔滨网站建设设计公司seo sem推广
  • 怎么做网页注册登录教程网站seo站长工具
  • 搜狐快站做网站教程网站域名查询
  • 50个产品改良设计seo的工作原理
  • 做网站外快怎么找关键词
  • 四川建设报名系统官网成都自然排名优化
  • 北京手机版建站系统开发广东网络优化推广
  • 合肥电子商务开发网站建设share群组链接分享
  • 一般ps做网站大小多少今日国内最新新闻
  • 建设银行发卡银行网站东莞seo优化
  • 长沙市住房和城乡建设委员会门户网站微信广告怎么投放
  • 凡科快图软件下载seo关键词推广话术
  • wordpress erphpdowns关键词优化是什么意思
  • 从事高端网站建设东莞网络推广
  • 建设网站技术数据策划书刷关键词排名seo软件
  • 网站建设企业公司steam交易链接怎么看
  • 福建泉州做网站公司哪家好友情链接作用
  • 网站的关于页面手机优化软件
  • 株洲市建设局网站毛局长semir森马
  • 建筑公司网站新闻注册一个网站
  • 长沙做网站公司seogw
  • 网站首页新增悬浮小窗怎么做引擎网站推广法
  • 做网站一般用什么软件人民网疫情最新消息
  • 装修公司网站源码php优化师助理
  • 网上下载的asp网站源码 放在本地如何做测试网络策划与营销
  • app手机软件开发公司关键词seo是什么