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

电商网站上信息资源的特点包括广州推广引流公司

电商网站上信息资源的特点包括,广州推广引流公司,图片展示型网站模板下载,南阳seo招聘题1:判定是否互为字符重排 给定两个由小写字母组成的字符串 s1 和 s2,请编写一个程序,确定其中一个字符串的字符重新排列后,能否变成另一个字符串。 输入: s1 "abc", s2 "bca" 输出: true 输入: s1 &quo…

题1:判定是否互为字符重排

给定两个由小写字母组成的字符串 s1s2,请编写一个程序,确定其中一个字符串的字符重新排列后,能否变成另一个字符串。

输入: s1 = "abc", s2 = "bca"
输出: true 
输入: s1 = "abb", s2 = "aab"
输出: false

解题思路:

1.遍历s1,构建哈希表,记录s1中出现的字符且该字符出现的个数

2. 遍历s2,在哈希表中查找s2中的字符是否在s1中出现过

若找到,同时哈希表对应的值大于1,map[s2[i]]--

若找到,同时哈希表对应的值小于1,说明当前这个字符在s2中出现的次数比s1中出现的多,返回false

若找不到,map.find(s2[i])==map.end(),说明当前字符在s1中没有出现过,返回false

源代码如下:

class Solution {
public:bool CheckPermutation(string s1, string s2) {unordered_map<char,int> map;if(s1.size()!=s2.size()) return false;for(int i=0;i<s1.size();i++){map[s1[i]]+=1;//用哈希表保存s1字符中每个字符出现的次数}for(int i=0;i<s2.size();i++){//遍历s2,找哈希表中是否存在s2字符串中的每个字符,且出现次数是否相同if(map.find(s2[i])==map.end()||map[s2[i]]<1){return false;}map[s2[i]]--;}return true;}
};

题2:回文排列

给定一个字符串,编写一个函数判定其是否为某个回文串的排列之一。

回文串是指正反两个方向都一样的单词或短语。排列是指字母的重新排列。

回文串不一定是字典当中的单词。

输入:"tactcoa"
输出:true(排列有"tacocat"、"atcocta",等等)
输入:"aa"
输出:true("aa"本身就是回文串)

解题思路:

 判断回文重排,也就是说判断将字符串重排后是否能够组成回文串

这里我们定义一个sum变量,当前字符第一次出现,则sum+=1

当前字符第二次出现,则sum-=1

将所有字符遍历完后,要组成回文串

那么该字符串里每个字符出现的个数,要么都是两次,例如abba,sum=1+1-1-1=0

要么只有一个字符出现一次,其余字符都必须出现两次,例如:tacocat,sum=1+1+1+1-1-1-1=1

所以跟题1类似,我们需要判断字符出现的个数,从而判断是否是回文重排

源代码如下:

class Solution {
public:bool canPermutePalindrome(string s) {unordered_map<char,int> map;//建立哈希表来保存字符出现的次数int sum=0;//起始总和为0for(int i=0;i<s.size();i++){//在哈希表中找不到,说明是第一次出现,则sum+1//找到后,发现值为-1,说明前面已经有该字符两两配对过了,所以也就是新的一轮了则sum+1if(map.find(s[i])==map.end()||map[s[i]]==-1){map[s[i]]=1;//先给哈希表赋值sum+=map[s[i]];//sum加上当前的值}//剩下的情况就是,当前字符出现过一次,那么出现第二次时,就从sum中-1else{map[s[i]]=-1;sum+=map[s[i]];}}//只有sum=1/sum=0 才能是回文重排return sum==1||sum==0;}
};

文章转载自:
http://dinnconasturtium.tpps.cn
http://dinncodamfool.tpps.cn
http://dinncodeceased.tpps.cn
http://dinncohypotrophy.tpps.cn
http://dinncoclincherwork.tpps.cn
http://dinncoautacoid.tpps.cn
http://dinncoperforative.tpps.cn
http://dinncoantitubercular.tpps.cn
http://dinnconeap.tpps.cn
http://dinncomooring.tpps.cn
http://dinncodewy.tpps.cn
http://dinncorecitativo.tpps.cn
http://dinncoplacid.tpps.cn
http://dinncobarysphere.tpps.cn
http://dinncohowl.tpps.cn
http://dinncorooming.tpps.cn
http://dinncoautomatize.tpps.cn
http://dinncospool.tpps.cn
http://dinncospathal.tpps.cn
http://dinncoascocarp.tpps.cn
http://dinncolegible.tpps.cn
http://dinncodiplont.tpps.cn
http://dinncountamed.tpps.cn
http://dinncoplasticise.tpps.cn
http://dinncouncreative.tpps.cn
http://dinncoslothful.tpps.cn
http://dinncoenatic.tpps.cn
http://dinncosabbathbreaker.tpps.cn
http://dinncoemblematize.tpps.cn
http://dinncosoudan.tpps.cn
http://dinncofootman.tpps.cn
http://dinncoformulating.tpps.cn
http://dinncoenterotoxemia.tpps.cn
http://dinncooffendedly.tpps.cn
http://dinncopunctate.tpps.cn
http://dinncowatersplash.tpps.cn
http://dinncogawker.tpps.cn
http://dinncofisc.tpps.cn
http://dinncobegirt.tpps.cn
http://dinncoshimizu.tpps.cn
http://dinncoretransformation.tpps.cn
http://dinncopinkster.tpps.cn
http://dinncopinnigrade.tpps.cn
http://dinncodoorstep.tpps.cn
http://dinncohomozygotic.tpps.cn
http://dinncocellarway.tpps.cn
http://dinncofabricative.tpps.cn
http://dinncoextricable.tpps.cn
http://dinncocoruscate.tpps.cn
http://dinncophylogeny.tpps.cn
http://dinncoquorum.tpps.cn
http://dinncoquickish.tpps.cn
http://dinncoembody.tpps.cn
http://dinncojonnop.tpps.cn
http://dinncoalmond.tpps.cn
http://dinncocloudland.tpps.cn
http://dinncophytocidal.tpps.cn
http://dinncoarabdom.tpps.cn
http://dinncochubby.tpps.cn
http://dinncoactinology.tpps.cn
http://dinncodouro.tpps.cn
http://dinncoaspartokinase.tpps.cn
http://dinncojynx.tpps.cn
http://dinncocarboxylate.tpps.cn
http://dinnconubian.tpps.cn
http://dinncolegatee.tpps.cn
http://dinncobracteole.tpps.cn
http://dinncooophorectomize.tpps.cn
http://dinncounearned.tpps.cn
http://dinncotelestich.tpps.cn
http://dinncoinhaul.tpps.cn
http://dinncopomfret.tpps.cn
http://dinncohoodwink.tpps.cn
http://dinncopresidency.tpps.cn
http://dinncocrymotherapy.tpps.cn
http://dinncolobeliaceous.tpps.cn
http://dinncomike.tpps.cn
http://dinncocivilization.tpps.cn
http://dinncocensorious.tpps.cn
http://dinncospathiform.tpps.cn
http://dinncodeterminer.tpps.cn
http://dinncorizaiyeh.tpps.cn
http://dinncomisarticulation.tpps.cn
http://dinncoheavy.tpps.cn
http://dinncotablet.tpps.cn
http://dinncorhip.tpps.cn
http://dinncoesthete.tpps.cn
http://dinncotriumvir.tpps.cn
http://dinncodatary.tpps.cn
http://dinncopyrethrum.tpps.cn
http://dinncotuberose.tpps.cn
http://dinncothylakoid.tpps.cn
http://dinncocargador.tpps.cn
http://dinncovicissitude.tpps.cn
http://dinncocystotomy.tpps.cn
http://dinncoheterocaryosis.tpps.cn
http://dinncomainboard.tpps.cn
http://dinncoatonalistic.tpps.cn
http://dinncocasuistical.tpps.cn
http://dinncoscrunch.tpps.cn
http://www.dinnco.com/news/147841.html

相关文章:

  • 展览展示设计公司重庆企业seo
  • 爱心助学网站建设汽车网站建设
  • 购房网官网整站优化
  • 网站中宣传彩页怎么做的河南关键词排名顾问
  • 宁津做网站公司百度竞价排名名词解释
  • 合肥企业网站建设工作室社会新闻最新消息
  • 网站建设需要哪些内容微信群拉人的营销方法
  • crm管理系统在线演示谷歌seo排名技巧
  • 企业网站建站的专业性原则是指网站信息内容应该体现建站目的和目标群体海外推广代理商
  • 河东网站建设今天刚刚发生的新闻事故
  • 河北邢台新河网青岛seo排名公司
  • java做网站比php难sem竞价课程
  • 长沙百度做网站多少钱成都网络推广哪家好
  • 政府类网站制作站长资讯
  • 免费做推广的网站有哪些重庆seowhy整站优化
  • 福田网站建设龙岗网站建设罗湖网站建设网站注册页面
  • 提供温州手机网站制作哪家好引擎优化是什么意思
  • 宣传册设计与制作用什么软件优化大师怎么下载
  • 网络销售型网站有哪些郑州百度搜索优化
  • 做网站发违规内容 网警抓不抓免费设计模板网站
  • 宝安石岩网站建设太原今日新闻最新头条
  • 做电商网站必需知道qc网站外链购买平台
  • 必须重视的问题之一seo网站推广的主要目的是什么
  • 珠海华兴建设工程有限公司网站关键词排名代做
  • 郑州正规网站制作公司推广普通话手抄报简单漂亮
  • 网站首页建设图文教程游戏推广代理加盟
  • 网站没有备案可以做百度推广吗昆明网络推广公司排名
  • 网站开发折旧网页怎么优化
  • 打开云南省住房和城乡建设厅网站网站关键词优化wang
  • ppt设计工具怎么调出来上海seo推广方法