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

中国建设银行官网站网点电商产品推广方案范文

中国建设银行官网站网点,电商产品推广方案范文,王也语录,景观设计网当我们遇到了要快速判断一个元素是否出现集合里的时候#xff0c;就要考虑哈希法。哈希法是牺牲了空间换取了时间#xff0c;要使用额外的数组#xff0c;set或者是map来存放数据#xff0c;才能实现快速的查找。当我们要使用集合来解决哈希问题的时候#xff0c;优先使用…当我们遇到了要快速判断一个元素是否出现集合里的时候就要考虑哈希法。哈希法是牺牲了空间换取了时间要使用额外的数组set或者是map来存放数据才能实现快速的查找。当我们要使用集合来解决哈希问题的时候优先使用unordered_set因为它的查询和增删效率是最优的如果需要集合是有序的那么就用set如果要求不仅有序还要有重复数据的话那么就multiset。而map 是一个key value 的数据结构map中对key是有限制对value没有限制的。242、有效的字母异位词 242、有效的字母异位词介绍给定两个字符串 s 和 t 编写一个函数来判断 t 是否是 s 的字母异位词。注意若 s 和 t 中每个字符出现的次数都相同则称 s 和 t 互为字母异位词。思路暴力思路两层for循环一层for循环遍历字符串另一个for循环遍历另一个字符串看第一个for循环中的字符有没有出现过。哈希法数组范围可控、set范围很大、mapkey--value本题中a-z中ASCII码是连续的。a可以对应到数组下标位0的位置z可以对应到数据下表为25的位置。因此可以定义一个数组hash[26];用该数组统计第一个字符串里每个字符出现的频率。然后第二个字符串每个字符出现的频率在数组的基础上做减法。如果最后数组hash中的所有元素都为0那么就是有效字母异位词。//定义哈希数组,默认该数组中的值为0 int hash[26]; for(i0;is.size;i){hash[s[i]-a]; } for(i0;it.size;i){hash[t[i]-a]--;} for(i0;i26;i){if(hash[i]!0)return false; } return true;代码class Solution { public:bool isAnagram(string s, string t) {int hash[26] {0};for(int i0;is.size();i){hash[s[i]-a];}for(int i0;it.size();i){hash[t[i]-a]--;}for(int i0;i26;i){if(hash[i]!0)return false;}return true;} };349、两个数组的交集349、两个数组的交集介绍给定两个数组 nums1 和 nums2 返回 它们的交集 。输出结果中的每个元素一定是 唯一 的。我们可以 不考虑输出结果的顺序 。思路一 数值很大使用set若数值很大可以使用set来做哈希映射。若数值很大但是分布很分散也可以用set。将nums1数组放到哈希表里然后遍历nums2的元素查看每个元素是否在哈希表中出现若出现则放到新数组中并且最后要去重。set在C中setunordered_set(无限存装的数组) 做映射和取值操作时效率最高multi_setunordered_set result (unordered_set会自动做去重) unordered_set number_set(nums1) //直接把nums1数组转变为unordered_set存储结构 //使用num2在number_set中做遍历查询操作 for(i0;inums2.sizei){if(number_set.find(nums2[i]) ! nums_set.end()) //如果找到了该元素result.inset(nums2[i]) } return vector(result...)思路二 数值较小使用数组定义一个1005的数组unordered_set result; int hash[1005]{0} //把nums1处理成哈希表结构 for(i0;inums1.size;i){hash[nums1[i]] 1; } //遍历nums2 for(i0;inums2.size;i){if(hash[nums2[i]] 1)result.insert(nums2[i]) }代码class Solution { public:vectorint intersection(vectorint nums1, vectorint nums2) {unordered_setint result;//unordered_set会自动去重unordered_setint nums_set(nums1.begin(),nums1.end());for(int i0;inums2.size();i){//find方法如果没找到该元素在哈希表中则会返回endif(nums_set.find(nums2[i])!nums_set.end())result.insert(nums2[i]);}return vectorint(result.begin(),result.end());} };class Solution { public:vectorint intersection(vectorint nums1, vectorint nums2) {unordered_setint result;//unordered_set会自动去重int hash[1005] {0};//把nums1处理成哈希表结构for(int i0;inums1.size();i){hash[nums1[i]] 1;}//遍历nums2for(int i0;inums2.size();i){if(hash[nums2[i]]1)result.insert(nums2[i]);}return vectorint(result.begin(),result.end());} };202、快乐数202、快乐数介绍思路如何求一个数中每一位的平方和。明确无限循环的概念即如果新的平方和在之前的计算中出现过因此可以想到使用哈希表)那么这就算一个无限循环。代码class Solution { public:int getSum(int n){int sum 0;while(n){sum sum (n%10)*(n%10);n n/10;}return sum;}bool isHappy(int n) {unordered_setint set;//定义存储每次的平方和while(1){int sum getSum(n);if(sum 1)return true;// 如果这个sum在set中出现过那么就说明陷入无限循环要立即跳出if(set.find(sum)!set.end()){return false;}else{set.insert(sum);}n sum;}} };1、两数之和1、两数之和介绍给定一个整数数组 nums 和一个整数目标值 target请你在该数组中找出 和为目标值 target 的那 两个 整数并返回它们的数组下标。你可以假设每种输入只会对应一个答案。但是数组中同一个元素在答案里不能重复出现。你可以按任意顺序返回答案。思路每当遇到要判断这个元素是否出现过的第一反应就应该是哈希法。例如如果遍历到3就应该判断前面是否遍历过6。如何判断是否遍历过将遍历过的元素加入到一个集合里。每次遍历新元素x的时候在这个集合里判断9-x是否出现过。集合---采用一种哈希表的结构--由于不仅要找一个元素还要知道这个元素在原数组中的下标所以应该选用map结构。map的key和value---思考我们查找的是什么我们查找的是一个元素是否出现过那么就应该将元素作为map中的key。map能以很快的速度查找key【这里的元素】是否在map中出现过map在该题中是存放我们遍历过的元素。//map--unordered_map(存和读效率最高)--multi_map //首先定义一个map要定义该map的key和value,用于存放遍历过的元素 unordered_map(int,int) map; for(i0;inums.size;i){//查询每个元素是否在map中s target - nums[i] //要查询的keyiter map.find(s);if(iter!map.end()) //如果要查询的key在map中出现过return {iter-value,i};map.insert(nums[i],i);//把遍历过的元素加入到map中 } return {};代码class Solution { public:vectorint twoSum(vectorint nums, int target) {std::unordered_mapint,int map;for(int i0;inums.size();i){//查询每个元素是否在map中int s target - nums[i];auto iter map.find(s);if(iter!map.end())return {iter-second,i};map.insert(pairint,int(nums[i],i));}return {};} };
文章转载自:
http://www.morning.bchhr.cn.gov.cn.bchhr.cn
http://www.morning.yqkxr.cn.gov.cn.yqkxr.cn
http://www.morning.mhcft.cn.gov.cn.mhcft.cn
http://www.morning.ykrss.cn.gov.cn.ykrss.cn
http://www.morning.ndngj.cn.gov.cn.ndngj.cn
http://www.morning.wnmdt.cn.gov.cn.wnmdt.cn
http://www.morning.fmkjx.cn.gov.cn.fmkjx.cn
http://www.morning.xfyjn.cn.gov.cn.xfyjn.cn
http://www.morning.ljdhj.cn.gov.cn.ljdhj.cn
http://www.morning.hqykb.cn.gov.cn.hqykb.cn
http://www.morning.gdpai.com.cn.gov.cn.gdpai.com.cn
http://www.morning.zstbc.cn.gov.cn.zstbc.cn
http://www.morning.zmzdx.cn.gov.cn.zmzdx.cn
http://www.morning.bqyb.cn.gov.cn.bqyb.cn
http://www.morning.mztyh.cn.gov.cn.mztyh.cn
http://www.morning.fsfz.cn.gov.cn.fsfz.cn
http://www.morning.mnygn.cn.gov.cn.mnygn.cn
http://www.morning.mplld.cn.gov.cn.mplld.cn
http://www.morning.smnxr.cn.gov.cn.smnxr.cn
http://www.morning.qpqb.cn.gov.cn.qpqb.cn
http://www.morning.lcxdm.cn.gov.cn.lcxdm.cn
http://www.morning.ncfky.cn.gov.cn.ncfky.cn
http://www.morning.rckmz.cn.gov.cn.rckmz.cn
http://www.morning.gfprf.cn.gov.cn.gfprf.cn
http://www.morning.ktfbl.cn.gov.cn.ktfbl.cn
http://www.morning.jytrb.cn.gov.cn.jytrb.cn
http://www.morning.tgdys.cn.gov.cn.tgdys.cn
http://www.morning.iqcge.com.gov.cn.iqcge.com
http://www.morning.rdlong.com.gov.cn.rdlong.com
http://www.morning.fwdln.cn.gov.cn.fwdln.cn
http://www.morning.xtqr.cn.gov.cn.xtqr.cn
http://www.morning.yhxhq.cn.gov.cn.yhxhq.cn
http://www.morning.cdlewan.com.gov.cn.cdlewan.com
http://www.morning.jqjnl.cn.gov.cn.jqjnl.cn
http://www.morning.vibwp.cn.gov.cn.vibwp.cn
http://www.morning.xysdy.cn.gov.cn.xysdy.cn
http://www.morning.lmmyl.cn.gov.cn.lmmyl.cn
http://www.morning.jkpnm.cn.gov.cn.jkpnm.cn
http://www.morning.lgcqj.cn.gov.cn.lgcqj.cn
http://www.morning.qtqjx.cn.gov.cn.qtqjx.cn
http://www.morning.sjwzl.cn.gov.cn.sjwzl.cn
http://www.morning.homayy.com.gov.cn.homayy.com
http://www.morning.lczxm.cn.gov.cn.lczxm.cn
http://www.morning.bwxph.cn.gov.cn.bwxph.cn
http://www.morning.zmzdx.cn.gov.cn.zmzdx.cn
http://www.morning.nsyzm.cn.gov.cn.nsyzm.cn
http://www.morning.smdkk.cn.gov.cn.smdkk.cn
http://www.morning.zwxfj.cn.gov.cn.zwxfj.cn
http://www.morning.jqjnx.cn.gov.cn.jqjnx.cn
http://www.morning.mcqhb.cn.gov.cn.mcqhb.cn
http://www.morning.rhdqz.cn.gov.cn.rhdqz.cn
http://www.morning.fbnsx.cn.gov.cn.fbnsx.cn
http://www.morning.ysjjr.cn.gov.cn.ysjjr.cn
http://www.morning.cyjjp.cn.gov.cn.cyjjp.cn
http://www.morning.rbbgh.cn.gov.cn.rbbgh.cn
http://www.morning.bsqth.cn.gov.cn.bsqth.cn
http://www.morning.lpcpb.cn.gov.cn.lpcpb.cn
http://www.morning.mrtdq.cn.gov.cn.mrtdq.cn
http://www.morning.mhnb.cn.gov.cn.mhnb.cn
http://www.morning.bmsqq.cn.gov.cn.bmsqq.cn
http://www.morning.kaylyea.com.gov.cn.kaylyea.com
http://www.morning.nhzxd.cn.gov.cn.nhzxd.cn
http://www.morning.rpkl.cn.gov.cn.rpkl.cn
http://www.morning.gpmrj.cn.gov.cn.gpmrj.cn
http://www.morning.brhxd.cn.gov.cn.brhxd.cn
http://www.morning.lxwjx.cn.gov.cn.lxwjx.cn
http://www.morning.hmdyl.cn.gov.cn.hmdyl.cn
http://www.morning.sqxr.cn.gov.cn.sqxr.cn
http://www.morning.hrtfz.cn.gov.cn.hrtfz.cn
http://www.morning.taipinghl.cn.gov.cn.taipinghl.cn
http://www.morning.mqbzk.cn.gov.cn.mqbzk.cn
http://www.morning.lgrkr.cn.gov.cn.lgrkr.cn
http://www.morning.nktgj.cn.gov.cn.nktgj.cn
http://www.morning.jkpnm.cn.gov.cn.jkpnm.cn
http://www.morning.kzslk.cn.gov.cn.kzslk.cn
http://www.morning.nwbnt.cn.gov.cn.nwbnt.cn
http://www.morning.qftzk.cn.gov.cn.qftzk.cn
http://www.morning.dpgdj.cn.gov.cn.dpgdj.cn
http://www.morning.qmzhy.cn.gov.cn.qmzhy.cn
http://www.morning.ydfr.cn.gov.cn.ydfr.cn
http://www.tj-hxxt.cn/news/278622.html

相关文章:

  • 中山网站开发公司企业信息查询
  • 建设全球购多用户商城网站莆田专业建站公司
  • 大连哪里有手机自适应网站建设wordpress h1标签优化
  • 网站设计怎么写龙岗建设高端网站
  • 哪里有门户网站开发公司网页设计文案
  • 做一套网站开发多少钱wordpress 宝典 pdf
  • html5经典网站网站制作企业
  • 网站重要组成部分邀请注册推广赚钱的app
  • 一个域名对应多个网站蒲城县住房和城乡建设局网站
  • 网站免费模板制作万网 成品网站
  • 如何做网站安全加固网站版建设
  • 微网站销售十堰互联网公司
  • 昆明网站建设电话南京建设网站制作
  • 微信登录 网站开发网站建设技术保证怎么写
  • 搜狗站长管理平台东莞公共资源交易中心官网
  • 泉州安溪县住房和城乡建设网站沧州网站设计多少钱
  • 网站前端用什么做中企动力做网站的优势
  • 溧水区住房城乡建设局网站深圳市招聘网站
  • 做一婚恋网站多少钱服装网站建设案例分析
  • 标题制作网站wordpress网站图片迁移
  • 五个推进网站建设工作做任务打字赚钱的网站
  • 网站开发投标书手机做网站公司有哪些
  • 网站建设及推广好学习吗别墅效果图制作
  • 网站投放广告费用龙岗附近做网站公司哪家好
  • 找做网站页的在哪找辽宁大连建设工程信息网
  • 代码库网站app开发公司电话
  • 网站设计昆明温州网站制作网站
  • 接做网站的管理培训课程
  • h5特效网站欣赏郑州微网站制作
  • asp网站开发实例pdf南京学习网站建设