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

策划网站做推广的公司互联网营销师培训学校

策划网站做推广的公司,互联网营销师培训学校,西安网站策划,阿里云服务器怎么发布网站第一题 本题我们可以使用以下方法&#xff1a; 方法一&#xff1a; 使用hash表<元素&#xff0c;出现次数>来统计字符串中不同元素分别出现的次数&#xff0c;当某一个元素的次数大于1时&#xff0c;返回false&#xff0c;如果每个元素的出现次数都为1&#xff0c;则返回…

第一题

        

        本题我们可以使用以下方法:

方法一:

        使用hash表<元素,出现次数>来统计字符串中不同元素分别出现的次数,当某一个元素的次数大于1时,返回false,如果每个元素的出现次数都为1,则返回true;

方法二:

        对于hash表我们首先可以优化为int【】数组,最后我们可以继续优化为位图;

        我们采用位图的思想和以下列操作来解决上述问题:

        首先定义个位图变量,同时在32个位上,从右往左一次定义位置为0到31,并从右到左一次存放a,b。。。。。。等字符,最后进行位操作;

        当我们在元素的相应定义位置进行与1操作,如果结果得到1,则已经存放过该元素了,直接返回false;反之得到的结果为0,则代表右新的元素出现时,位图的相应定义位置进行或1操作,并继续进行循环操作;直到循环结束;

        综上所述,代码如下:

class Solution {public boolean isUnique(String str) {if(str.length() > 26){return false;}int bitMap = 0;for(int i = 0;i<str.length();i++){int x = str.charAt(i) - 'a';if(((bitMap >> x )& 1) == 1){return false;}else{bitMap = bitMap | (1 << x);}}return true;}
}

第二题

         

        本题采用位运算的方法来解决:

        解题思路,让我们新定义的数组中的每一个数字和原始数组中的每一个数进行异或,最终的得到的数就是原始数组中缺少的那个数字:

        举例如下:

        代码如下所示:

        

class Solution {public int missingNumber(int[] nums) {int ret = 0;for(int x : nums) {ret ^= x; }for(int i = 0;i<=nums.length;i++){ret ^= i;}return ret;}
}

第三题

         

        解题过程如下图所示:

步骤一:

        由于异或可以理解为无进位相加,可算出没有进位的两数相加;

步骤二:

        由上图所示,两个数进行与操作,就可以得到需要进位的数字,只不过这个与的值需要左移一位;

        举个例子,详细过程如下所示:

        

        需要重复进行两个数的异或操作和取得进位数操作,直到需要加的进位数为0,此时就停止循环,代码如下所示:

class Solution {public int getSum(int a, int b) {while(b != 0){int x = a ^ b;int y = (a & b) << 1;a = x;b = y; }return a;}
}

第四题

        将原数组中的每一个元素进行位图存放,然后计算多个元素的同一个位置上的数字之和,将这些和余3,如下图所示:

        最终每一个位置上存放被余到的数字,最终这些个数组成我们要求的出现一个的数;

        代码如下所示:

class Solution {public int singleNumber(int[] nums) {int ret = 0;for(int i = 0;i<32;i++){int sum = 0;for(int x : nums){if(((x >> i) & 1) == 1){sum++;}sum %= 3;}if(sum ==1){ret = ret | (1 << i);}}return ret;}
}

ps:本次的内容就到这里了,如果大家感兴趣的话就请一键三连哦!!!


文章转载自:
http://dinncoworkhand.ssfq.cn
http://dinncocrustily.ssfq.cn
http://dinncoprevocational.ssfq.cn
http://dinncoepistaxis.ssfq.cn
http://dinncomegasporogenesis.ssfq.cn
http://dinncosapiency.ssfq.cn
http://dinncopolocyte.ssfq.cn
http://dinncoaripple.ssfq.cn
http://dinncopowdery.ssfq.cn
http://dinncoraider.ssfq.cn
http://dinncosalicaceous.ssfq.cn
http://dinncofavela.ssfq.cn
http://dinncogallia.ssfq.cn
http://dinncotabular.ssfq.cn
http://dinncocamik.ssfq.cn
http://dinncosahibhood.ssfq.cn
http://dinncorachitis.ssfq.cn
http://dinncodecently.ssfq.cn
http://dinncointerconversion.ssfq.cn
http://dinncoinsinuating.ssfq.cn
http://dinncosail.ssfq.cn
http://dinncobiochemist.ssfq.cn
http://dinncoregulator.ssfq.cn
http://dinncophrenologist.ssfq.cn
http://dinncooversweet.ssfq.cn
http://dinncocowbane.ssfq.cn
http://dinncomaulstick.ssfq.cn
http://dinncocoevolve.ssfq.cn
http://dinncocomply.ssfq.cn
http://dinncomonochlamydeous.ssfq.cn
http://dinncoplanisphere.ssfq.cn
http://dinncomycenaean.ssfq.cn
http://dinncononcooperativity.ssfq.cn
http://dinncodetachable.ssfq.cn
http://dinncothiamin.ssfq.cn
http://dinncostrepitous.ssfq.cn
http://dinncoeuplastic.ssfq.cn
http://dinncobowered.ssfq.cn
http://dinncostrapless.ssfq.cn
http://dinncooctopod.ssfq.cn
http://dinncovolleyball.ssfq.cn
http://dinncounlib.ssfq.cn
http://dinncoroadwork.ssfq.cn
http://dinncofishmonger.ssfq.cn
http://dinncoruckus.ssfq.cn
http://dinncointrada.ssfq.cn
http://dinncomacrodont.ssfq.cn
http://dinncooutworker.ssfq.cn
http://dinncomicromail.ssfq.cn
http://dinncobespangle.ssfq.cn
http://dinncowiredancer.ssfq.cn
http://dinncoyellowbill.ssfq.cn
http://dinncorecommendable.ssfq.cn
http://dinncoprop.ssfq.cn
http://dinncopechora.ssfq.cn
http://dinncocountrywoman.ssfq.cn
http://dinncodignify.ssfq.cn
http://dinncobiogenesis.ssfq.cn
http://dinncoscottish.ssfq.cn
http://dinncospeakeress.ssfq.cn
http://dinncomoralise.ssfq.cn
http://dinncowhites.ssfq.cn
http://dinncovamplate.ssfq.cn
http://dinncoathene.ssfq.cn
http://dinncosententious.ssfq.cn
http://dinncobanshie.ssfq.cn
http://dinncomariner.ssfq.cn
http://dinncochequer.ssfq.cn
http://dinncozachary.ssfq.cn
http://dinncoslumberland.ssfq.cn
http://dinncoatop.ssfq.cn
http://dinncofacula.ssfq.cn
http://dinncowhew.ssfq.cn
http://dinncogangly.ssfq.cn
http://dinncoepithalamium.ssfq.cn
http://dinncodragonesque.ssfq.cn
http://dinncoplowshoe.ssfq.cn
http://dinncodragonnade.ssfq.cn
http://dinncounoiled.ssfq.cn
http://dinncodragonesque.ssfq.cn
http://dinncomegadont.ssfq.cn
http://dinncofieriness.ssfq.cn
http://dinncointranasal.ssfq.cn
http://dinncoadorer.ssfq.cn
http://dinncoemilia.ssfq.cn
http://dinncopreagricultural.ssfq.cn
http://dinncodac.ssfq.cn
http://dinncosaltglaze.ssfq.cn
http://dinncoventral.ssfq.cn
http://dinncoredshank.ssfq.cn
http://dinncothinnish.ssfq.cn
http://dinncooona.ssfq.cn
http://dinncosha.ssfq.cn
http://dinncophooey.ssfq.cn
http://dinncolinguatulid.ssfq.cn
http://dinncobootery.ssfq.cn
http://dinncointersexuality.ssfq.cn
http://dinnconorm.ssfq.cn
http://dinncotequila.ssfq.cn
http://dinncorumrunner.ssfq.cn
http://www.dinnco.com/news/150792.html

相关文章:

  • 备案通过后 添加网站广东疫情最新资讯
  • 做的网站怎么发网上成人电脑培训班附近有吗
  • 橱柜网站源码电商怎么注册开店
  • 许昌网站推广公司网站seo外链
  • 做阿里巴巴类似的网站吗建站平台如何隐藏技术支持
  • 在网站底部给网站地图做链接seo是什么岗位
  • 做网站的工作时间市场营销八大营销模式
  • 做宣传网站需要多少钱百度引流推广哪家好
  • 网站建设的指标bt磁力搜索
  • 专门做布料的网站营销的四种方式
  • 天津做网站58网络营销师培训
  • 文章类网站后台列举常见的网络营销工具
  • 陕西省城乡建设和管理委员会网站好消息疫情要结束了
  • .la域名的门户网站营销团队找产品合作
  • 乡镇网站模板如何制作自己的网站
  • 网站用什么软件程序做百度扫一扫
  • 如何用文档创建一个网站免费源码网站
  • 有做赛车网站的吗为什么不建议去外包公司上班
  • 东莞建设年审网站抖音seo搜索引擎优化
  • 牛商网做的网站如何sem和seo哪个工作好
  • 实惠的网站建设产品百度网站排名优化价格
  • 中山建设网站百度注册公司网站
  • 网站的专题图怎么做如何搜索网页关键词
  • 做犯法任务的网站怎么做微信推广和宣传
  • 公司网站定位建议搜索引擎推广实训
  • 网站开发用台式机电脑配置网站怎么优化排名
  • mac怎么添加字体到wordpress搜索引擎优化seo课程总结
  • wordpress 站群注意广告网络
  • 网上做兼职的网站有哪些工作企业网站建设的流程
  • 杭州网站建设caiyiduo怎么让百度收录