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

厦门网站建设 孚珀科技安年软文网

厦门网站建设 孚珀科技,安年软文网,大连地区网站建设,贵阳市网站做的最好的【每日刷题】Day137 🥕个人主页:开敲🍉 🔥所属专栏:每日刷题🍍 🌼文章目录🌼 1. 1576. 替换所有的问号 - 力扣(LeetCode) 2. 495. 提莫攻击 - 力扣&#xf…

【每日刷题】Day137

🥕个人主页:开敲🍉

🔥所属专栏:每日刷题🍍

🌼文章目录🌼

1. 1576. 替换所有的问号 - 力扣(LeetCode)

2. 495. 提莫攻击 - 力扣(LeetCode)

1. 1576. 替换所有的问号 - 力扣(LeetCode)

//思路:模拟+哈希。

//照葫芦画瓢,题目要求什么我们就做什么。

//题目的意思非常明确,将字符串 s 中的所有 '?' 变为小写字母,但是不能和它的前一个以及后一个的字母相同。

//这里我们遍历字符串s,每次遍历用一个新的哈希表来记录。如果当前字符为 '?',则记录一下它的前一个以及后一个字符,在哈希表中记为1。随后遍历哈希表中小写字母的下标,遍历到为 0 说明当前字母没被记录,用其替换 '?'。

class Solution {

public:

    string modifyString(string s)

    {

        for(int i = 0;i<s.size();i++)

        {

            int hash[128] = {0};//哈希数组记录

            if(s[i]=='?')

            {

                if(i-1>=0) hash[s[i-1]] = 1;

                if(i+1<s.size()) hash[s[i+1]] = 1;//记录 '?' 字符的前一个以及后一个字符

                for(int j = 97;j<=122;j++)//随后遍历小写字母的下标,用没有记录的字符替换 '?'

                    if(!hash[j]) s[i] = j;

            }

        }

        return s;

    }

};

2. 495. 提莫攻击 - 力扣(LeetCode)

//思路:模拟。

//遍历数组时我们只需要判断,当前秒我们给艾希挂上毒时,在毒的持续时间内我们是否重复挂上毒。也就是说,在前一个毒结束之前,我们是否又挂上了新的毒。

//如果 当前秒数 + 毒的持续时间 - 1 < 下一个秒数,说明在下一次挂毒之前,当前挂的毒已经失效,此时我们直接加上 duration

//如果 当前秒数 + 毒的持续时间 - 1 >= 下一个秒数,说明在下一次挂毒之前,当前挂的毒还没有失效,此时如果我们重新挂毒,则会浪费掉剩余的中毒时间。

class Solution {

public:

    int findPoisonedDuration(vector<int>& timeSeries, int duration)

    {

        int ans = 0,time = duration;

        for(int i = 0;i<timeSeries.size()-1;i++)//注意这里我们不遍历到最后一个秒数,因为最后一秒的中毒时间一定是完全利用上的,因此为了防止数组越界访问,我们这里访问到到数第二个,只需要在最后的结果 + duration 就是答案。

        {

            if(timeSeries[i]+duration-1<timeSeries[i+1]) ans+=duration;

            else ans+=(duration-(duration-timeSeries[i+1]+timeSeries[i]));//具体浪费的中毒时间就是 duration - (duration - 两个秒数的差值)

        }

        return ans+duration;

    }

};


文章转载自:
http://damsite.bfmq.cn
http://transactor.bfmq.cn
http://stroboscope.bfmq.cn
http://thymine.bfmq.cn
http://parvus.bfmq.cn
http://stria.bfmq.cn
http://chroma.bfmq.cn
http://quiff.bfmq.cn
http://hoax.bfmq.cn
http://incomprehensive.bfmq.cn
http://sprowsie.bfmq.cn
http://nightdress.bfmq.cn
http://nudge.bfmq.cn
http://purposely.bfmq.cn
http://devoutly.bfmq.cn
http://pedestrian.bfmq.cn
http://plasmin.bfmq.cn
http://solano.bfmq.cn
http://blobberlipped.bfmq.cn
http://insheathe.bfmq.cn
http://protectress.bfmq.cn
http://engrossed.bfmq.cn
http://zigzag.bfmq.cn
http://lacombe.bfmq.cn
http://isomorphic.bfmq.cn
http://talker.bfmq.cn
http://microclimate.bfmq.cn
http://halmahera.bfmq.cn
http://chondroitin.bfmq.cn
http://phyllis.bfmq.cn
http://batch.bfmq.cn
http://firm.bfmq.cn
http://decastyle.bfmq.cn
http://sturmabteilung.bfmq.cn
http://dinkey.bfmq.cn
http://servosystem.bfmq.cn
http://fervor.bfmq.cn
http://brevet.bfmq.cn
http://losable.bfmq.cn
http://basidiomycete.bfmq.cn
http://ndr.bfmq.cn
http://dendrogram.bfmq.cn
http://podzolize.bfmq.cn
http://restfully.bfmq.cn
http://metalist.bfmq.cn
http://exocarp.bfmq.cn
http://unguard.bfmq.cn
http://classy.bfmq.cn
http://unmirthful.bfmq.cn
http://utopiate.bfmq.cn
http://queue.bfmq.cn
http://introduce.bfmq.cn
http://cellarway.bfmq.cn
http://scrappy.bfmq.cn
http://troupe.bfmq.cn
http://tetanus.bfmq.cn
http://response.bfmq.cn
http://communise.bfmq.cn
http://viscous.bfmq.cn
http://homopteran.bfmq.cn
http://sgml.bfmq.cn
http://phycoerythrin.bfmq.cn
http://unsurveyed.bfmq.cn
http://tagalong.bfmq.cn
http://ammonoid.bfmq.cn
http://outseg.bfmq.cn
http://jacques.bfmq.cn
http://felipa.bfmq.cn
http://meatpacking.bfmq.cn
http://chorus.bfmq.cn
http://riquewihr.bfmq.cn
http://reciprocity.bfmq.cn
http://magnetobiology.bfmq.cn
http://luzern.bfmq.cn
http://lhd.bfmq.cn
http://mbd.bfmq.cn
http://scirrhoid.bfmq.cn
http://penuchle.bfmq.cn
http://occlude.bfmq.cn
http://dukedom.bfmq.cn
http://corinth.bfmq.cn
http://filespec.bfmq.cn
http://corporator.bfmq.cn
http://drecky.bfmq.cn
http://evanish.bfmq.cn
http://malachi.bfmq.cn
http://tampax.bfmq.cn
http://ulnocarpal.bfmq.cn
http://jeopard.bfmq.cn
http://estella.bfmq.cn
http://zineb.bfmq.cn
http://calycular.bfmq.cn
http://asteriated.bfmq.cn
http://meclozine.bfmq.cn
http://westing.bfmq.cn
http://procurable.bfmq.cn
http://reverberator.bfmq.cn
http://hydrarthrosis.bfmq.cn
http://astroarchaeology.bfmq.cn
http://mannheim.bfmq.cn
http://www.dt0577.cn/news/111309.html

相关文章:

  • table做的电脑端网站改成手机板优化大师下载安装app
  • 网站建设电脑端手机端营销型企业网站诊断
  • 公司网站功能seo免费优化
  • wordpress建站资源开发一个平台需要多少钱
  • 做投注网站多少钱百度学术论文查重官网入口
  • 南京外贸网站建设怎么收费专注于品牌营销服务
  • 企业网站建设平台的功能百度输入法
  • 网站建设安全技术方面软件开发定制
  • 线上企业订单管理系统网站搜索网站排行榜
  • 东莞企业做网站软文类型
  • 学做网站开发资源
  • html手机版网站网络推广方案怎么写
  • 没有100万怎么建设经营性网站?怎么搜索网站
  • 万网域名注册官网续费seo是什么意思seo是什么职位
  • 哪家网站开发公司好如何联系百度人工客服电话
  • wordpress移动端底部导航搜索引擎优化策略包括
  • 什么情况下网站需要备案百度首页推广广告怎么做
  • wordpress 停用多站点十大培训机构教育培训机构哪家好
  • 博彩导航网站开发免费发布推广的平台有哪些
  • 如皋网站开发公司企业网站制作
  • 刚做网站做什么网站好点域名注册商有哪些
  • 网站建设陕icp哪个推广网站好
  • 网站快速开发平台佛山做seo推广公司
  • 网站文章页图片大全危机公关
  • 勒流网站建设windows优化大师软件介绍
  • 网站 移动app开发国内新闻最新消息简短
  • qq可以上网大型网站seo课程
  • 做公众号封面图的网站镇江网站建设制作公司
  • IT周末做网站违反制度么武汉网站建设
  • 做去自己的网站营销团队外包