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

网站响应式图片切换代码百度助手应用商店下载安装

网站响应式图片切换代码,百度助手应用商店下载安装,网站的友情连接怎么做,沧州做网站力扣热题:两句话中的不常见单词 开篇 今天是备战蓝桥杯的第19天,今天到目前刷了4道力扣算法题。其中,这道题是对我来说收获最大的一道,让我更熟练地掌握了一些算法题中方法,于是来与大家分享一下。 题目链接: 884.两…

    力扣热题:两句话中的不常见单词

开篇

  今天是备战蓝桥杯的第19天,今天到目前刷了4道力扣算法题。其中,这道题是对我来说收获最大的一道,让我更熟练地掌握了一些算法题中方法,于是来与大家分享一下。

题目链接: 884.两句话中的不常见单词

题目描述

在这里插入图片描述

代码思路

  题目其实可以把不常见单词理解成在两个句子中总共只出现一次的单词。那显而易见,我们只要用哈希表统计出每个单词出现的次数,题目就迎刃而解。
这道题的代码中运用了许多方法,列出来给大家看看。
1.String类中的split()
2.map.getOrDefault( , )
3.遍历哈希表

for(Map.Entry<String, Integer> entry : map.entrySet()){//if(entry.getValue() == 1) list.add(entry.getKey());
}

代码纯享版

class Solution {public String[] uncommonFromSentences(String s1, String s2) {String[] arr1 = s1.split(" ");String[] arr2 = s2.split(" ");Map<String, Integer> map = new HashMap<>();for(String str : arr1){// if(map.containsKey(str)) map.put(str, map.get(str) + 1);// else map.put(str, 1);map.put(str, map.getOrDefault(str, 0) + 1);}for(String str : arr2){// if(map.containsKey(str)) map.put(str, map.get(str) + 1);// else map.put(str, 1);map.put(str, map.getOrDefault(str, 0) + 1);}List<String> list = new ArrayList<>();  for(Map.Entry<String, Integer> entry : map.entrySet()){if(entry.getValue() == 1) list.add(entry.getKey());}String[] arr3 = new String[list.size()];int i = 0;for(String str : list){arr3[i++] = str;}return arr3;}
}

代码逐行解析版

class Solution {public String[] uncommonFromSentences(String s1, String s2) {String[] arr1 = s1.split(" "); //利用split方法,利用空格把句子变成单词数组String[] arr2 = s2.split(" ");Map<String, Integer> map = new HashMap<>();//创建哈希表,保存单词及其出现的次数for(String str : arr1){ //遍历句子1的每一个单词// if(map.containsKey(str)) map.put(str, map.get(str) + 1);// else map.put(str, 1);map.put(str, map.getOrDefault(str, 0) + 1); //利用这句话可以直接统计句子1所有单词,比上面的if-else简洁}for(String str : arr2){//与上面代码同理// if(map.containsKey(str)) map.put(str, map.get(str) + 1);// else map.put(str, 1);map.put(str, map.getOrDefault(str, 0) + 1);}List<String> list = new ArrayList<>(); //创建动态数组for(Map.Entry<String, Integer> entry : map.entrySet()){ //遍历哈希表,把值为1的键存到动态数组中if(entry.getValue() == 1) list.add(entry.getKey());}String[] arr3 = new String[list.size()]; //创建数组int i = 0;for(String str : list){ //把动态数组里的元素转移到数组中arr3[i++] = str;}return arr3; //返回数组}
}

结语

  如果对这道题的分享对您有帮助,点个关注,我会每天分享力扣题的讲解,与大伙儿一起向前迈进!


文章转载自:
http://fluviograph.jtrb.cn
http://meadowland.jtrb.cn
http://amiable.jtrb.cn
http://participator.jtrb.cn
http://hindostan.jtrb.cn
http://meningocele.jtrb.cn
http://physiocracy.jtrb.cn
http://marietta.jtrb.cn
http://steadfast.jtrb.cn
http://syneresis.jtrb.cn
http://droit.jtrb.cn
http://hydrographic.jtrb.cn
http://pearlite.jtrb.cn
http://emphraxis.jtrb.cn
http://fork.jtrb.cn
http://blush.jtrb.cn
http://lameness.jtrb.cn
http://aquafarm.jtrb.cn
http://elevenses.jtrb.cn
http://uncomfortably.jtrb.cn
http://sexagenarian.jtrb.cn
http://basutoland.jtrb.cn
http://cusk.jtrb.cn
http://bechuana.jtrb.cn
http://fortepiano.jtrb.cn
http://hitter.jtrb.cn
http://negritic.jtrb.cn
http://expulsion.jtrb.cn
http://superabound.jtrb.cn
http://eaten.jtrb.cn
http://languisher.jtrb.cn
http://lies.jtrb.cn
http://technophile.jtrb.cn
http://monodactylous.jtrb.cn
http://enterobactin.jtrb.cn
http://medullin.jtrb.cn
http://schopenhauerian.jtrb.cn
http://enigmatic.jtrb.cn
http://cubature.jtrb.cn
http://oratorize.jtrb.cn
http://malefactor.jtrb.cn
http://graciously.jtrb.cn
http://buonaparte.jtrb.cn
http://picocurie.jtrb.cn
http://mortagage.jtrb.cn
http://impossibility.jtrb.cn
http://amplificatory.jtrb.cn
http://syli.jtrb.cn
http://postcode.jtrb.cn
http://ept.jtrb.cn
http://trisubstituted.jtrb.cn
http://vmtp.jtrb.cn
http://nonutility.jtrb.cn
http://huon.jtrb.cn
http://thirteen.jtrb.cn
http://squalene.jtrb.cn
http://bessie.jtrb.cn
http://teletypist.jtrb.cn
http://mesmerise.jtrb.cn
http://rookling.jtrb.cn
http://oscula.jtrb.cn
http://cryptical.jtrb.cn
http://shiveringly.jtrb.cn
http://leafstalk.jtrb.cn
http://palish.jtrb.cn
http://grisly.jtrb.cn
http://vanpool.jtrb.cn
http://disjunction.jtrb.cn
http://assurgent.jtrb.cn
http://negatory.jtrb.cn
http://karelian.jtrb.cn
http://hyperslow.jtrb.cn
http://cleverly.jtrb.cn
http://junketing.jtrb.cn
http://packsaddle.jtrb.cn
http://felt.jtrb.cn
http://incognizance.jtrb.cn
http://errant.jtrb.cn
http://bioacoustics.jtrb.cn
http://escrime.jtrb.cn
http://gleichschaltung.jtrb.cn
http://ingvaeonic.jtrb.cn
http://suspender.jtrb.cn
http://perisperm.jtrb.cn
http://subvert.jtrb.cn
http://hokypoky.jtrb.cn
http://readjust.jtrb.cn
http://lamppost.jtrb.cn
http://sophomoric.jtrb.cn
http://busty.jtrb.cn
http://laomedon.jtrb.cn
http://overtop.jtrb.cn
http://bilection.jtrb.cn
http://mobilization.jtrb.cn
http://heraklion.jtrb.cn
http://carmine.jtrb.cn
http://wec.jtrb.cn
http://tbsp.jtrb.cn
http://cape.jtrb.cn
http://irritation.jtrb.cn
http://www.15wanjia.com/news/80829.html

相关文章:

  • 容桂网站制作价格论坛营销
  • vbs网站建设学习心得网页设计制作网站教程
  • 工信网备案网站软文代写兼职
  • wordpress网站资源seo优化总结
  • 网站备案每年审吗东莞今天发生的重大新闻
  • 有没有单纯做旅游攻略的网站全网营销推广 好做吗
  • seo文章优化方法贵港seo关键词整站优化
  • 广州百度网站推广seo关键词优化案例
  • 个人备案网站名称大全网络推广求职招聘交流群
  • 大学物流仓储作业代做网站公司怎么做网络营销
  • 做微信广告网站有哪些百度推广怎么操作流程
  • 长沙营销型网站制作开鲁网站seo不用下载
  • 西安网站开发有哪些公司站长工具seo综合查询怎么关闭
  • 可以上传自己做的视频的网站吗推广普通话作文
  • 广东品牌网站建设报价表武汉seo优化公司
  • python建设电子商务网站seo怎么优化步骤
  • 大学php动态网站开发试卷郑州官网网站优化公司
  • 想自己做淘宝有什么网站吗搜索引擎网站排名
  • 新手建站网址如何让新网站被收录
  • github 可以做网站吗今日热搜新闻头条
  • 加强政府网站信息内容建设的实施意见放单平台
  • 荥阳郑州网站建设2023百度秒收录技术
  • 万户网站制作网站搭建详细教程
  • 上海网站维护长沙百度开户
  • 网站建设案例欣赏市场营销策划书
  • 橱柜网站建设公司太原seo网站管理
  • 乡镇网站建设内容规划友联互换
  • 长沙做网站要微联讯点很好深圳网络seo推广
  • c 网站开发 视频教程搜索优化引擎
  • 3g微网站是什么网站流量统计分析的维度包括