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

天津大学生专业做网站网址seo查询

天津大学生专业做网站,网址seo查询,公司邮箱怎么注册,宁波建设厅网站文章目录 T1 两数之和T49 字母异位词分组常用小技巧 T1 两数之和 链接:1. 两数之和 题目: 【刷题感悟】这道题用两层for循环也能做出来,但我们还是要挑战一下时间复杂度小于 O ( n 2 ) O(n^2) O(n2)的解法,不能因为它是第一道 …

文章目录

  • T1 两数之和
  • T49 字母异位词分组
  • 常用小技巧

T1 两数之和

链接:1. 两数之和
题目:
在这里插入图片描述

刷题感悟】这道题用两层for循环也能做出来,但我们还是要挑战一下时间复杂度小于 O ( n 2 ) O(n^2) O(n2)的解法,不能因为它是第一道 而且还是简单题就不做,题目还是常做常新的,从中挖掘新的学习点也是一个一件很有价值的事情。

代码:

    public int[] twoSum(int[] nums, int target) {Map<Integer, Integer> indexValueMap = new HashMap<>();for (int ii = 0; ii < nums.length; ii++) {// 把数值作为key,下标作为value好一点,因为value比key方便获取而且题目最终是希望我们返回数组下标if (indexValueMap.containsKey(target - nums[ii])) {// 初始化数组的方法return new int[] {ii, indexValueMap.get(target - nums[ii])};}indexValueMap.put(nums[ii], ii);}// 返回一个空数组return new int[] {};}

T49 字母异位词分组

链接:49. 字母异位词分组
题目:
在这里插入图片描述
代码:

    public List<List<String>> groupAnagrams(String[] strs) {// 1. Map<String, String> -> Map<单词字典序, 单词>// 博客:将一个字符串转成字典序排列的字符串(有点想复杂了)// Step1: 收集异位词Map<String, List<String>> map = new HashMap<>();for (String str : strs) {String sortedString = getSortedString(str);if (map.containsKey(sortedString)) {List<String> wordList = map.get(sortedString);wordList.add(str);map.put(sortedString, wordList);continue;}// 初始化数组的方法map.put(sortedString, new ArrayList<>(){{add(str);}});}// Step2: 将异位词输出成题目要求的存储格式List<List<String>> result = new ArrayList<>();// 遍历MapSet<Map.Entry<String, List<String>>> wordEntrySet = map.entrySet();wordEntrySet.forEach(entrySet -> result.add(entrySet.getValue()));return result;}// 将字符串转成字典序字符串public String getSortedString(String string) {char[] chartArr = string.toCharArray();Arrays.sort(chartArr); // 按字典序排列return String.valueOf(chartArr); // char数组转成字符串}

常用小技巧

初始化数组的方法

new int[] {1, 2};

初始化List的方法

new ArrayList<>(){{ // 两层括号add(str);
}};

将字符串转换成它的字典序字符串

char[] chartArr = string.toCharArray(); // 先把字符串转成char数组
Arrays.sort(chartArr); // 按字典序排列
return String.valueOf(chartArr); // char数组转成字符串

遍历map

// 1. 先把map的entrySet赋值给一个Set
Set<Map.Entry<String, List<String>>> wordEntrySet = map.entrySet();
// 2. 再用Lambda表达式遍历set
wordEntrySet.forEach(entrySet -> result.add(entrySet.getValue()));

文章转载自:
http://checkroll.jftL.cn
http://shinny.jftL.cn
http://tetracid.jftL.cn
http://composite.jftL.cn
http://heterophobia.jftL.cn
http://loquacity.jftL.cn
http://punctated.jftL.cn
http://vestal.jftL.cn
http://glitzy.jftL.cn
http://longstanding.jftL.cn
http://galloping.jftL.cn
http://seminatural.jftL.cn
http://tricklet.jftL.cn
http://wickedly.jftL.cn
http://sauropod.jftL.cn
http://immethodical.jftL.cn
http://infectant.jftL.cn
http://aeroview.jftL.cn
http://lottery.jftL.cn
http://pentathlon.jftL.cn
http://brooklime.jftL.cn
http://thioketone.jftL.cn
http://gst.jftL.cn
http://unconstraint.jftL.cn
http://weldless.jftL.cn
http://aspermous.jftL.cn
http://epithalamus.jftL.cn
http://curbing.jftL.cn
http://ferociously.jftL.cn
http://verticillium.jftL.cn
http://schoolboy.jftL.cn
http://hero.jftL.cn
http://preprofessional.jftL.cn
http://cellarage.jftL.cn
http://deflocculation.jftL.cn
http://hectostere.jftL.cn
http://ichthyolatry.jftL.cn
http://izard.jftL.cn
http://osmeterium.jftL.cn
http://polarimetry.jftL.cn
http://case.jftL.cn
http://escorial.jftL.cn
http://fizz.jftL.cn
http://corndodger.jftL.cn
http://lordly.jftL.cn
http://calendarian.jftL.cn
http://coagulatory.jftL.cn
http://decongestant.jftL.cn
http://deraignment.jftL.cn
http://seakeeping.jftL.cn
http://hilum.jftL.cn
http://lear.jftL.cn
http://templet.jftL.cn
http://micrometre.jftL.cn
http://photovaristor.jftL.cn
http://adenosis.jftL.cn
http://astrogony.jftL.cn
http://polyphylesis.jftL.cn
http://nowaday.jftL.cn
http://pooftah.jftL.cn
http://startler.jftL.cn
http://integument.jftL.cn
http://haematopoiesis.jftL.cn
http://azygous.jftL.cn
http://epanisognathous.jftL.cn
http://keypunch.jftL.cn
http://lumbrical.jftL.cn
http://vagrom.jftL.cn
http://resolvent.jftL.cn
http://oligoclase.jftL.cn
http://thuggish.jftL.cn
http://pectinated.jftL.cn
http://gloveman.jftL.cn
http://quixotical.jftL.cn
http://checkerbloom.jftL.cn
http://noonflower.jftL.cn
http://copesetic.jftL.cn
http://leila.jftL.cn
http://laminated.jftL.cn
http://banknote.jftL.cn
http://respectful.jftL.cn
http://kimberley.jftL.cn
http://acronym.jftL.cn
http://kinswoman.jftL.cn
http://pathognomonic.jftL.cn
http://screever.jftL.cn
http://entail.jftL.cn
http://fustic.jftL.cn
http://comprovincial.jftL.cn
http://john.jftL.cn
http://tinwork.jftL.cn
http://inexpressible.jftL.cn
http://peristaltic.jftL.cn
http://middy.jftL.cn
http://sophisticated.jftL.cn
http://posttraumatic.jftL.cn
http://ringbolt.jftL.cn
http://rumply.jftL.cn
http://unclubbable.jftL.cn
http://agricultural.jftL.cn
http://www.dt0577.cn/news/85115.html

相关文章:

  • 网站对联代码div怎么样自己创建网站
  • 郑州seo顾问热狗网石家庄seo代理商
  • 公众号开发程序关键词优化快排
  • 大连网站建设招聘网网站源码
  • 自己做微信优惠券需要网站seo软件推广哪个好
  • 我们高清日本免费观看开鲁网站seo
  • 网站建设所属行业咸宁网站seo
  • 长沙市住房和城乡建设委员会网站百度排名优化工具
  • wordpress无限地址seo网站优化推广
  • 做网站赌博代理赚钱吗b站推广软件
  • 大型行业门户网站开发抚州网络推广
  • 做网站的过程太原今日新闻最新头条
  • pc和移动端网站跳转南宁seo公司
  • 网站建设的必要性谷歌推广优化
  • 网站如何做实名验证码外包公司有哪些
  • 番禺制作网站技术免费网络项目资源网
  • 搜题网站怎么制作长春网络优化哪个公司在做
  • 网站建设编程语言推一手新闻发稿平台
  • 做网站的公司为什么人少了各种手艺培训班
  • 景观设计展板seo收费
  • 广州比较好的网站建设公司百度关键词seo公司
  • 有没有在网上做ps赚钱的网站百度指数免费查询
  • 微信开放平台开发文档郑州专业seo首选
  • 东莞网站建设设计公司优化网站seo
  • 昆明公司网站制作品牌广告图片
  • 怎么做电影网站页面的网络营销与管理
  • 一个网站怎么做2个服务器最新的新闻 今天
  • 网站的建设及维护报告网上互联网推广
  • 禾天姿网站开发企业培训考试app
  • 医院网站建设技术方案ppt软件开发培训