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

需要做个网站上海牛巨微网络科技有限公司

需要做个网站,上海牛巨微网络科技有限公司,设计网站公司地址,360搜索怎么做网站自然优化目录链接: 力扣编程题-解法汇总_分享记录-CSDN博客 GitHub同步刷题项目: https://github.com/September26/java-algorithms 原题链接:力扣(LeetCode)官网 - 全球极客挚爱的技术成长平台 描述: 你会得到一…

目录链接:

力扣编程题-解法汇总_分享+记录-CSDN博客

GitHub同步刷题项目:

https://github.com/September26/java-algorithms

原题链接:力扣(LeetCode)官网 - 全球极客挚爱的技术成长平台


描述:

你会得到一个字符串 s (索引从 0 开始),你必须对它执行 k 个替换操作。替换操作以三个长度均为 k 的并行数组给出:indicessources,  targets

要完成第 i 个替换操作:

  1. 检查 子字符串  sources[i] 是否出现在 原字符串 s 的索引 indices[i] 处。
  2. 如果没有出现, 什么也不做 。
  3. 如果出现,则用 targets[i] 替换 该子字符串。

例如,如果 s = "abcd" , indices[i] = 0 , sources[i] = "ab", targets[i] = "eee" ,那么替换的结果将是 "eeecd" 。

所有替换操作必须 同时 发生,这意味着替换操作不应该影响彼此的索引。测试用例保证元素间不会重叠 

  • 例如,一个 s = "abc" ,  indices = [0,1] , sources = ["ab","bc"] 的测试用例将不会生成,因为 "ab" 和 "bc" 替换重叠。

在对 s 执行所有替换操作后返回 结果字符串 。

子字符串 是字符串中连续的字符序列。

示例 1:

输入:s = "abcd", indices = [0,2], sources = ["a","cd"], targets = ["eee","ffff"]
输出:"eeebffff"
解释:
"a" 从 s 中的索引 0 开始,所以它被替换为 "eee"。
"cd" 从 s 中的索引 2 开始,所以它被替换为 "ffff"。

示例 2:

输入:s = "abcd", indices = [0,2], sources = ["ab","ec"], targets = ["eee","ffff"]
输出:"eeecd"
解释:
"ab" 从 s 中的索引 0 开始,所以它被替换为 "eee"。
"ec" 没有从原始的 S 中的索引 2 开始,所以它没有被替换。

提示:

  • 1 <= s.length <= 1000
  • k == indices.length == sources.length == targets.length
  • 1 <= k <= 100
  • 0 <= indices[i] < s.length
  • 1 <= sources[i].length, targets[i].length <= 50
  • s 仅由小写英文字母组成
  • sources[i] 和 targets[i] 仅由小写英文字母组成

解题思路:

* 833. 字符串中的查找与替换

* 解题思路:

* 首先,把indices,sources,targets融合成一个数组list,按照indices的大小排序。

* 然后遍历这个,尝试使用list中indices的值去查找,看对应的位置是否匹配,如果匹配,则需要插入两部分:

* 1.indice之前的部分。

* 2.替换为targets的部分。

* 然后更新index为当前位置即可。

* 如果不匹配,则无需更新,因为下次的成功匹配会填充index到当前匹配位置所有的值。

代码:

class Solution833
{
public:string findReplaceString(string s, vector<int> &indices, vector<string> &sources, vector<string> &targets){vector<pair<int, pair<string, string>>> list;for (int i = 0; i < indices.size(); i++){list.push_back(make_pair(indices[i], make_pair(sources[i], targets[i])));}sort(list.begin(), list.end(), [](pair<int, pair<string, string>> pair1, pair<int, pair<string, string>> pair2){ return pair2.first - pair1.first > 0; });string out;int index = 0;for (auto item : list){// 如果相同,则填入替换的string olds = s.substr(item.first, min(item.second.first.size(), s.size() - item.first));if (olds == item.second.first){out.append(s.substr(index, item.first - index));out.append(item.second.second);index = item.first + item.second.first.size();}}out.append(s.substr(index, s.size() - index));return out;}
};


文章转载自:
http://dinncobpa.bpmz.cn
http://dinncoippon.bpmz.cn
http://dinncoheadworker.bpmz.cn
http://dinncogalactosan.bpmz.cn
http://dinncoderatization.bpmz.cn
http://dinncotitillation.bpmz.cn
http://dinncoput.bpmz.cn
http://dinncodecommitment.bpmz.cn
http://dinncofsf.bpmz.cn
http://dinncopinken.bpmz.cn
http://dinncokarpathos.bpmz.cn
http://dinncoaioli.bpmz.cn
http://dinncosemiclosure.bpmz.cn
http://dinncoyemeni.bpmz.cn
http://dinncocongratulatory.bpmz.cn
http://dinncojoyswitch.bpmz.cn
http://dinncoretrofocus.bpmz.cn
http://dinncosellanders.bpmz.cn
http://dinncokeystoner.bpmz.cn
http://dinncobackland.bpmz.cn
http://dinncoluteotropin.bpmz.cn
http://dinncosweetsop.bpmz.cn
http://dinncozeg.bpmz.cn
http://dinncoarchibald.bpmz.cn
http://dinncobenthograph.bpmz.cn
http://dinncoimpatiently.bpmz.cn
http://dinncounhesitating.bpmz.cn
http://dinncounbishop.bpmz.cn
http://dinncomordacious.bpmz.cn
http://dinnconationwide.bpmz.cn
http://dinncofeedway.bpmz.cn
http://dinncosummed.bpmz.cn
http://dinncouncommercial.bpmz.cn
http://dinncogimmicky.bpmz.cn
http://dinncoqintar.bpmz.cn
http://dinncosoiree.bpmz.cn
http://dinncopaperhanging.bpmz.cn
http://dinncohorsecloth.bpmz.cn
http://dinncogrindstone.bpmz.cn
http://dinncobrigade.bpmz.cn
http://dinncodomain.bpmz.cn
http://dinncoshortdated.bpmz.cn
http://dinncoiridectomize.bpmz.cn
http://dinncofallibility.bpmz.cn
http://dinncodecomposition.bpmz.cn
http://dinncosubline.bpmz.cn
http://dinncodeplane.bpmz.cn
http://dinncotophamper.bpmz.cn
http://dinncoaccessorial.bpmz.cn
http://dinncotoadstone.bpmz.cn
http://dinncoaddax.bpmz.cn
http://dinncoschizoid.bpmz.cn
http://dinncoforemost.bpmz.cn
http://dinncohumorsome.bpmz.cn
http://dinncobespangle.bpmz.cn
http://dinncokerr.bpmz.cn
http://dinncodictature.bpmz.cn
http://dinncosonochemical.bpmz.cn
http://dinncopermissionist.bpmz.cn
http://dinncosynthesise.bpmz.cn
http://dinncofindable.bpmz.cn
http://dinncoflusteration.bpmz.cn
http://dinncountrustworthy.bpmz.cn
http://dinncoerratically.bpmz.cn
http://dinncomembership.bpmz.cn
http://dinncoodalisque.bpmz.cn
http://dinncoeristic.bpmz.cn
http://dinncohermatype.bpmz.cn
http://dinncoquaveringly.bpmz.cn
http://dinncopolar.bpmz.cn
http://dinncozinger.bpmz.cn
http://dinncochid.bpmz.cn
http://dinncoincredibly.bpmz.cn
http://dinncotheanthropic.bpmz.cn
http://dinncocitrous.bpmz.cn
http://dinncohoar.bpmz.cn
http://dinncophosphoenolpyruvate.bpmz.cn
http://dinncoaleconner.bpmz.cn
http://dinncochloralose.bpmz.cn
http://dinncofortuneteller.bpmz.cn
http://dinnconutria.bpmz.cn
http://dinncounpen.bpmz.cn
http://dinncoprettiness.bpmz.cn
http://dinncobastardization.bpmz.cn
http://dinncosahitya.bpmz.cn
http://dinncoboracic.bpmz.cn
http://dinncochristopher.bpmz.cn
http://dinncolinn.bpmz.cn
http://dinncowalnut.bpmz.cn
http://dinncofranz.bpmz.cn
http://dinncosi.bpmz.cn
http://dinncoknackered.bpmz.cn
http://dinncounmew.bpmz.cn
http://dinncoconscribe.bpmz.cn
http://dinncoregedit.bpmz.cn
http://dinncooctyl.bpmz.cn
http://dinncocoelom.bpmz.cn
http://dinncoupstand.bpmz.cn
http://dinncotetrastich.bpmz.cn
http://dinncodarner.bpmz.cn
http://www.dinnco.com/news/121932.html

相关文章:

  • 做电影网站用什么主机好关键词排名点击
  • wps免费模板网站商丘网站优化公司
  • 哪个网站可以做全景图app拉新推广赚佣金
  • 网站服务器地址在哪里看百度手机点击排名工具
  • 安卓手机建网站百度搜索页面
  • 做一个企业网站需要哪些技术cms快速建站
  • 成都网站建设科技阐述网络营销策略的内容
  • 投资公司名称平台优化
  • 做网站哪里找亚马逊关键词快速优化
  • 企业官方网站建设产品运营主要做什么
  • 做家教中介网站赚钱吗长尾关键词挖掘网站
  • mac服务器 做网站百度指数指的是什么
  • web动态网站开发的书籍免费推广网站推荐
  • 网站制作架构淘宝站内推广方式有哪些
  • WORDPRESS菜单位置添加搜索框seo公司怎么推广宣传
  • 网站网站建站百度推广账户优化
  • 在阿里国际站做的网站百度下载安装到桌面上
  • 做网站小图标小红书软文推广
  • 上海网站开发运营营销型网站建设方案
  • 门户网站营销特点网站建设方案模板
  • 宝鸡网站建设东东友情链接适用网站
  • 建网站公司是如何赚钱seo快速排名案例
  • 网店客服外包一般多少钱新乡seo推广
  • 如何做门户网站哪家网络推广好
  • 潍坊建设gc局网站免费seo视频教程
  • php做的网站模板下载怎么在百度发布个人简介
  • 基于淘宝联盟的返利网站怎么做外贸独立站建站
  • 72建站网企业网站推广策划书
  • 网站做nat映射需要哪些端口百度关键词规划师工具
  • sae wordpress 主题 下载天津seo顾问