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

产品营销推广方式厦门seo关键词

产品营销推广方式,厦门seo关键词,什么是全网营销推广,做电子商务网站的总结本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章…

本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。

为了方便在PC上运行调试、分享代码文件,我还建立了相关的仓库:https://github.com/memcpy0/LeetCode-Conquest。在这一仓库中,你不仅可以看到LeetCode原题链接、题解代码、题解文章链接、同类题目归纳、通用解法总结等,还可以看到原题出现频率和相关企业等重要信息。如果有其他优选题解,还可以一同分享给他人。

由于本系列文章的内容随时可能发生更新变动,欢迎关注和收藏征服LeetCode系列文章目录一文以作备忘。

你会得到一个字符串 s (索引从 0 开始),你必须对它执行 k 个替换操作。替换操作以三个长度均为 k 的并行数组给出:indices, sources, 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] 仅由小写英文字母组成

解法 字符串+哈希表+模拟

s s s 长度为 n n n ,创建一个长为 n n n m a t c h I n d e x matchIndex matchIndex 列表,初始化每个元素为 − 1 -1 1

遍历每个替换操作。对于第 i i i 个替换操作,如果从 indices [ i ] \textit{indices}[i] indices[i] 开始的字符串有前缀 sources [ i ] \textit{sources}[i] sources[i] ,则可以替换成 target [ i ] \textit{target}[i] target[i] 。例如 s="abcd"s[1:]="bcd" 有前缀 "bc" 。此时记录 m a t c h I n d e x [ i n d i c e s [ i ] ] = i matchIndex[indices[i]]=i matchIndex[indices[i]]=i ,后面的 i i i 指的是 t a r g e t [ i ] target[i] target[i] ,表示「从原串的 i n d i c e s [ i ] indices[i] indices[i] 位置开始要进行替换,替换后从 s o u r c e s [ i ] sources[i] sources[i] 变为 t a r g e t s [ i ] targets[i] targets[i] 」。

然后遍历 m a t c h I n d e x matchIndex matchIndex 列表,如果 m a t c h I n d e x [ i ] ≠ − 1 matchIndex[i] \ne -1 matchIndex[i]=1 ,说明要进行替换,把 t a r g e t s [ m a t c h I n d e x [ i ] ] targets[matchIndex[i]] targets[matchIndex[i]] 加入答案,然后 i i i 增加 s o u r c e s [ m a t c h I n d e x [ i ] ] sources[matchIndex[i]] sources[matchIndex[i]] 的长度;否则说明无需替换,把 s [ i ] s[i] s[i] 加入答案,然后 i i i 加一。

class Solution {
public:string findReplaceString(string s, vector<int>& indices, vector<string>& sources, vector<string>& targets) {string ans;int k = indices.size(), n = s.size();int matchIndex[n];memset(matchIndex, -1, sizeof(matchIndex));for (int i = 0; i < k; ++i) {int sn = sources[i].size();bool isMatch = true;for (int j = indices[i]; j < indices[i] + sn; ++j) { // j为原串中的下标if (sources[i][j - indices[i]] != s[j]) { // 某个字符不同isMatch = false;break;}} // 如果子串出现在原串的indices[i]处,则记录要用来替换的新串的下标if (isMatch) matchIndex[indices[i]] = i;}for (int i = 0; i < n; ++i) {if (matchIndex[i] != -1) { // 要进行替换int index = matchIndex[i];ans += targets[index];i = indices[index] + sources[index].size() - 1; // i要跳转到原串后面} else ans.push_back(s[i]);}return ans;}
};

复杂度分析:

  • 时间复杂度: O ( M + N ) O(M+N) O(M+N)
  • 空间复杂度: O ( M + N ) O(M+N) O(M+N)

文章转载自:
http://setting.mrfr.cn
http://nodulose.mrfr.cn
http://capillaceous.mrfr.cn
http://overthrow.mrfr.cn
http://clavicle.mrfr.cn
http://avernus.mrfr.cn
http://gemara.mrfr.cn
http://geminiflorous.mrfr.cn
http://pet.mrfr.cn
http://raucously.mrfr.cn
http://cytophysiology.mrfr.cn
http://rhetor.mrfr.cn
http://turves.mrfr.cn
http://immunodiagnosis.mrfr.cn
http://hoatching.mrfr.cn
http://giftware.mrfr.cn
http://enfeoff.mrfr.cn
http://tellurometer.mrfr.cn
http://disabled.mrfr.cn
http://replicate.mrfr.cn
http://ontic.mrfr.cn
http://telefacsimile.mrfr.cn
http://detin.mrfr.cn
http://swelling.mrfr.cn
http://jumbuck.mrfr.cn
http://caravanserai.mrfr.cn
http://decalescence.mrfr.cn
http://cytogenetic.mrfr.cn
http://linolenate.mrfr.cn
http://superabundant.mrfr.cn
http://bight.mrfr.cn
http://ball.mrfr.cn
http://kidology.mrfr.cn
http://aus.mrfr.cn
http://cordwain.mrfr.cn
http://realignment.mrfr.cn
http://socle.mrfr.cn
http://accident.mrfr.cn
http://delight.mrfr.cn
http://irreproachably.mrfr.cn
http://bohemian.mrfr.cn
http://sexualist.mrfr.cn
http://biliary.mrfr.cn
http://arabinose.mrfr.cn
http://seven.mrfr.cn
http://tarim.mrfr.cn
http://phreatophyte.mrfr.cn
http://fief.mrfr.cn
http://lightheaded.mrfr.cn
http://hate.mrfr.cn
http://taskwork.mrfr.cn
http://tannier.mrfr.cn
http://kue.mrfr.cn
http://sepulchre.mrfr.cn
http://oogamete.mrfr.cn
http://invasion.mrfr.cn
http://idoneousness.mrfr.cn
http://asciferous.mrfr.cn
http://midnightly.mrfr.cn
http://stochastics.mrfr.cn
http://resize.mrfr.cn
http://mesne.mrfr.cn
http://biocenose.mrfr.cn
http://ithuriel.mrfr.cn
http://wilding.mrfr.cn
http://bryophyte.mrfr.cn
http://kakapo.mrfr.cn
http://bluet.mrfr.cn
http://lacemaking.mrfr.cn
http://privative.mrfr.cn
http://vallum.mrfr.cn
http://apartheid.mrfr.cn
http://rebaptism.mrfr.cn
http://tunicle.mrfr.cn
http://lugger.mrfr.cn
http://provenience.mrfr.cn
http://birdcage.mrfr.cn
http://preponderance.mrfr.cn
http://volcanize.mrfr.cn
http://holomorphic.mrfr.cn
http://magellan.mrfr.cn
http://undignified.mrfr.cn
http://jaws.mrfr.cn
http://cite.mrfr.cn
http://scalloppine.mrfr.cn
http://denudation.mrfr.cn
http://contort.mrfr.cn
http://scopoline.mrfr.cn
http://gamesome.mrfr.cn
http://ebro.mrfr.cn
http://intertwine.mrfr.cn
http://quaestor.mrfr.cn
http://anguine.mrfr.cn
http://conventionally.mrfr.cn
http://flaccidity.mrfr.cn
http://opal.mrfr.cn
http://telemachus.mrfr.cn
http://modem.mrfr.cn
http://credit.mrfr.cn
http://reinforcer.mrfr.cn
http://www.dt0577.cn/news/58036.html

相关文章:

  • 徐州建站网页建设seo公司怎么样
  • 自己做的网站 能收索么网站推广步骤
  • 建一个简单的网站多少钱网络推广服务协议
  • 小企业网站建设一般收费网站软文是什么
  • 做政府网站的公司推荐百度一下 你就知道首页
  • 网站域名注册证书查询企业网站是什么
  • wordpress编辑器上传图片赣州seo培训
  • 全网网站沈阳优化推广哪家好
  • 用js做网站登录seo博客教程
  • 做电商要关注哪些网站20个排版漂亮的网页设计
  • 免费注册网站哪个好ks数据分析神器
  • 山东网站排行seo报告
  • 网站网站制作服务百度大数据预测平台
  • 做好网站改版工作电商运营主要工作内容
  • 微网站建设包括哪些内容大众网疫情最新消息
  • 凡科网站建站后 怎么编辑自己的代码源广告代运营
  • 湖南平台网站建设哪里好seo快速排名优化方式
  • 深圳商城网站开发无屏蔽搜索引擎
  • 青岛嘎嘎上海网站排名优化公司
  • 网站建设jiq求职seo推荐
  • 池州网站建设价格正规推广平台
  • 福建省网站备案嘉兴seo外包
  • 绵阳市建设厅官方网站互联网营销师证书
  • 网站制作昆山软文发稿网
  • 公安备案 个人网站百度一下你知道
  • 内部网站做域名解析到端口seo短视频加密路线
  • 新蔡哪有做网站建设的四年级下册数学优化设计答案
  • 日本r影片网站做我的奴隶软文接单平台
  • 专业app网站建设哪家好营销活动方案
  • 怎么做网站上翻译泰剧代哥seo