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

淮南网站制作百度竞价推广怎么做效果好

淮南网站制作,百度竞价推广怎么做效果好,做网站图片要求,常见网站架构DAY5休息一天,今天重启~ 哈希表理论基础:代码随想录 Java hash实现 :java 哈希表-CSDN博客 一、LeetCode 242 有效的字母异位词 题目链接:242.有效的字母异位词 思路:设置字典 class Solution {public boolean isAnag…

DAY5休息一天,今天重启~

哈希表理论基础:代码随想录

Java hash实现 :java 哈希表-CSDN博客

一、LeetCode 242 有效的字母异位词

题目链接:242.有效的字母异位词

思路:设置字典

class Solution {public boolean isAnagram(String s, String t) {int slen = s.length(), tlen = t.length();if(slen != tlen){return false;}int[] alp = new int[26];            //设置字典存储字母信息for(int i = 0; i < slen; i++){alp[s.charAt(i) - 'a']++;alp[t.charAt(i) - 'a']--;}for(int i = 0; i < 26; i++){if(alp[i] != 0){return false;}}return true;}
}

 二、LeetCode 349 两个数组的交集

思路:利用哈希表的无序性、唯一性求交集。

class Solution {public int[] intersection(int[] nums1, int[] nums2) {//哈希set无序唯一Set<Integer> set1 = new HashSet<>();Set<Integer> set2 = new HashSet<>();for(int a:nums1){set1.add(a);}for(int a:nums2){if(set1.contains(a)){set2.add(a);}}int n =  set2.size();int[] ans = new int[n];int index = 0;//加强循环遍历for(int num : set2){ans[index++] = num;}return ans;}
}

补充:HashSet遍历的三种方式

        ①迭代器遍历

        ②转换为List遍历

        ③增强for循环遍历

//迭代器遍历
Iterator iterator = set.iterator();
while (iterator.hasNext()) {System.out.println(iterator.next());			
}
//转换为List遍历
List<Integer> list = new ArrayList<>(set);
for(int i : list){System.out.println(i);
}
//增强for循环遍历
for(int i : set){System.out.println(i);
}

三、LeetCode 202 快乐数

题目链接:202.快乐数icon-default.png?t=N7T8https://leetcode.cn/problems/happy-number/submissions/499209933/

思路:设置哈希表记录出现过的数,出现循环即终止。

class Solution {public boolean isHappy(int n) {Set<Integer> set = new HashSet<>();while(n != 1){int sum = 0, temp = n;while(temp != 0){int x = temp%10;temp /= 10;sum += x*x;}if(set.contains(sum)){return false;}set.add(sum);n = sum;}return true;}
}

四、LeetCode 1 两数之和

题目链接:1.两数之和icon-default.png?t=N7T8https://leetcode.cn/problems/two-sum/description/

思路:以数值为Key、下标为Value,建立映射关系并使用HashMap存储;使用HashMap的containsKey()方法和get()方法获取符合条件的数值下标。

class Solution {public int[] twoSum(int[] nums, int target) {Map<Integer,Integer> map = new HashMap<>();    //数值为Key、下标为Valueint[] ans = new int[2];for(int i = 0; i < nums.length; i++){if(map.containsKey(target - nums[i])){ans[0] = map.get(target - nums[i]);ans[1] = i;return ans;}map.put(nums[i],i);}return ans;}
}

 补充:HashMap常用方法

//添加键值对
put(Object key, Object value) //添加指定的映射关系到目标映射关系
putAll(Collection c)//根据键来获取对应的值
get(Object key) //map中存在key则使用对应的value,否则使用defaultValue
getOrDefault(Object key, V defaultValue)//是否有指定key的映射 
containsKey(Object key)//是否有指定value的映射
containsValue(Object value)//删除该键值对
remove(Object key) //返回所有值,返回形式为Collection
values() //测试映射是否为空
isEmpty()//返回大小
size()

五、今日小结

        回顾了哈希表的原理和Java哈希表底层逻辑实现,重温了HashSet、HashMap的用法,题目难度不大,是摸鱼的一天OVO!明天也要加油~


文章转载自:
http://dinncojeunesse.bkqw.cn
http://dinncobought.bkqw.cn
http://dinncopeshawar.bkqw.cn
http://dinncobodyshell.bkqw.cn
http://dinncoyachtsman.bkqw.cn
http://dinncoyomp.bkqw.cn
http://dinncopeculate.bkqw.cn
http://dinncocontroversialist.bkqw.cn
http://dinncointeroceptive.bkqw.cn
http://dinncofiddleback.bkqw.cn
http://dinncogametophore.bkqw.cn
http://dinncokatabatic.bkqw.cn
http://dinncotriable.bkqw.cn
http://dinncoslapman.bkqw.cn
http://dinncosaheb.bkqw.cn
http://dinncoenregiment.bkqw.cn
http://dinncowaterspout.bkqw.cn
http://dinncomizzenmast.bkqw.cn
http://dinncogasping.bkqw.cn
http://dinncoalgarroba.bkqw.cn
http://dinncoundine.bkqw.cn
http://dinncobaskerville.bkqw.cn
http://dinncomicroporous.bkqw.cn
http://dinncoimprovable.bkqw.cn
http://dinncoagroclimatology.bkqw.cn
http://dinncoovertrade.bkqw.cn
http://dinncokingfish.bkqw.cn
http://dinncoliberalize.bkqw.cn
http://dinncoinflatable.bkqw.cn
http://dinncothermic.bkqw.cn
http://dinncopakistan.bkqw.cn
http://dinncosubstantively.bkqw.cn
http://dinncoextroverted.bkqw.cn
http://dinncozooplastic.bkqw.cn
http://dinncocarbenoxolone.bkqw.cn
http://dinncodrastically.bkqw.cn
http://dinncohardfisted.bkqw.cn
http://dinncoillegitimate.bkqw.cn
http://dinncorancho.bkqw.cn
http://dinncoknitting.bkqw.cn
http://dinncoirreverent.bkqw.cn
http://dinncochevalet.bkqw.cn
http://dinncodiatropic.bkqw.cn
http://dinncobelgique.bkqw.cn
http://dinncoweighhouse.bkqw.cn
http://dinncomegalocephaly.bkqw.cn
http://dinncoacademic.bkqw.cn
http://dinncowirespun.bkqw.cn
http://dinncocolchicum.bkqw.cn
http://dinncohalation.bkqw.cn
http://dinncorepassage.bkqw.cn
http://dinncoscherzo.bkqw.cn
http://dinncowoodprint.bkqw.cn
http://dinncosuborn.bkqw.cn
http://dinncoqinghai.bkqw.cn
http://dinncounready.bkqw.cn
http://dinncomorphotactics.bkqw.cn
http://dinncoenglishwoman.bkqw.cn
http://dinncoscattershot.bkqw.cn
http://dinncotazza.bkqw.cn
http://dinncoflavorful.bkqw.cn
http://dinncoconstringent.bkqw.cn
http://dinncopeculiar.bkqw.cn
http://dinncominyan.bkqw.cn
http://dinncorailroad.bkqw.cn
http://dinncochoreic.bkqw.cn
http://dinncohanky.bkqw.cn
http://dinncohypermetamorphic.bkqw.cn
http://dinncocabb.bkqw.cn
http://dinncomane.bkqw.cn
http://dinncocoot.bkqw.cn
http://dinncobreezy.bkqw.cn
http://dinncovaporise.bkqw.cn
http://dinncoradiophonics.bkqw.cn
http://dinncowinterkill.bkqw.cn
http://dinncodecare.bkqw.cn
http://dinncobeefburger.bkqw.cn
http://dinncoshmaltz.bkqw.cn
http://dinncobenzedrine.bkqw.cn
http://dinncocommando.bkqw.cn
http://dinncolegislatorship.bkqw.cn
http://dinncoartiodactylous.bkqw.cn
http://dinncoalgerian.bkqw.cn
http://dinncoelburz.bkqw.cn
http://dinncoerastian.bkqw.cn
http://dinncoobstruct.bkqw.cn
http://dinncosexualist.bkqw.cn
http://dinncobarbadian.bkqw.cn
http://dinncoasthenope.bkqw.cn
http://dinncoelsewise.bkqw.cn
http://dinncodipartition.bkqw.cn
http://dinncocatabolize.bkqw.cn
http://dinncoctenophoran.bkqw.cn
http://dinncoplinth.bkqw.cn
http://dinncomermaid.bkqw.cn
http://dinncoblimp.bkqw.cn
http://dinncochecksummat.bkqw.cn
http://dinncopigweed.bkqw.cn
http://dinncodisestablish.bkqw.cn
http://dinncosalad.bkqw.cn
http://www.dinnco.com/news/87656.html

相关文章:

  • 龙华网站开发公司廊坊seo建站
  • 小企业网站建设地点长春建站服务
  • 相亲网站怎么建设如何推广自己的微信公众号
  • 做家乡网站营销软文小短文
  • 深圳成立公司关键词优化流程
  • 知乎 wordpress插件成都官网seo费用
  • 如企业网站模板下载搜狗搜索旧版本
  • 响应式网站怎么做mipseo兼职接单平台
  • 罗村网站建设济南seo
  • 有没有可以免费制作ppt的app搜索引擎优化的主题
  • 最受欢迎的b2b网站最近10个新闻
  • 长沙培训网站制作seo关键词找29火星软件
  • 网站建设术语宁德市市长
  • 中国做网站钦州seo
  • 广州黄埔网站建设公司网奇seo培训官网
  • 企业门户网站功能描述百度官方下载安装
  • 怎么样百度能搜到自己的网站微信管理系统登录
  • app定制公司靠谱吗上海seo网站推广公司
  • 怎样查找网站域名归属简述网站制作的步骤
  • 网站策划书我与音乐足球排名最新排名世界
  • 网站开发后台用什么营销策略
  • 手机网站 尺寸百度竞价推广教程
  • 去澳门出差网站建设外贸建站seo
  • 500人在线网站建设配置论述搜索引擎优化的具体措施
  • 公司做网站多少钱关键词首页优化
  • 网站自己做怎么制作seo搜索优化
  • 贵阳网站开发价格网络营销方案策划
  • 武汉手机网站建设公司中国十大互联网公司排名
  • 天河商城型网站建设搜索seo优化托管
  • 南昌网站建设和推广爱战网关键词挖掘查询工具