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

网站开发公司专业google官网入口手机版

网站开发公司专业,google官网入口手机版,那个做兼职网站好,深圳软件公司排行文章目录 Tag题目来源解题思路方法一:遍历方法二:getline 写在最后 Tag 【遍历】【getline】【字符串】【2024-01-20】 题目来源 2788. 按分隔符拆分字符串 解题思路 方法一:遍历 思路 分隔符在字符串开始和结束位置时不需要处理。 分隔…

文章目录

  • Tag
  • 题目来源
  • 解题思路
    • 方法一:遍历
    • 方法二:getline
  • 写在最后

Tag

【遍历】【getline】【字符串】【2024-01-20】


题目来源

2788. 按分隔符拆分字符串


解题思路

方法一:遍历

思路

分隔符在字符串开始和结束位置时不需要处理。

分隔符出现在字符串中间时,记录上一个分隔符到当前分隔符之间的字符串或者到字符串结尾的字符串,非空即可加入到答案数组中。

算法

class Solution {
public:vector<string> splitWordsBySeparator(vector<string>& words, char separator) {vector<string> res;for (auto& word : words) {word += '*';string tmp = "";int n = word.size();for (int i = 0; i < n; ++i) {// 分隔符在字符串开始和结尾处不用处理if (word[i] == separator && (i == 0 || i == n-1)) continue; // 分隔符只在字符串中间出现的情况if (word[i] == separator || word[i] == '*') {if (!tmp.empty()) {res.push_back(tmp);tmp = "";}  }else {tmp += word[i];}}}return res;}
};

复杂度分析

时间复杂度: O ( m × n ) O(m \times n) O(m×n) m m m 为字符串数组 words 的长度, n n n 为字符串 word 的长度。

空间复杂度: O ( n ) O(n) O(n)

方法二:getline

思路

使用 stringstream 中的 getline 操作,getline有一个重载后的版本为 getline (istream& is, string& str, char delim) 可以将输入的字符串 is 根据分隔符 delim 分割然后保存为 str

算法

class Solution {
public:vector<string> splitWordsBySeparator(vector<string>& words, char separator) {vector<string> res;for (const auto& word : words) {stringstream ss(word);string sub;while (getline(ss, sub, separator)) {if (!sub.empty()) {res.push_back(sub);}}}return res;}
};

复杂度分析

时间复杂度: O ( m × n ) O(m \times n) O(m×n) m m m 为字符串数组 words 的长度, n n n 为字符串 word 的长度。

空间复杂度: O ( n ) O(n) O(n)


写在最后

如果您发现文章有任何错误或者对文章有任何疑问,欢迎私信博主或者在评论区指出 💬💬💬。

如果大家有更优的时间、空间复杂度的方法,欢迎评论区交流。

最后,感谢您的阅读,如果有所收获的话可以给我点一个 👍 哦。


文章转载自:
http://dinncotularemia.wbqt.cn
http://dinncoincorporated.wbqt.cn
http://dinncoprussian.wbqt.cn
http://dinncosoapboxer.wbqt.cn
http://dinncomaui.wbqt.cn
http://dinncoumpteenth.wbqt.cn
http://dinncoswill.wbqt.cn
http://dinncothaneship.wbqt.cn
http://dinncokaratsu.wbqt.cn
http://dinncoabstract.wbqt.cn
http://dinncovsam.wbqt.cn
http://dinncohatchery.wbqt.cn
http://dinncosword.wbqt.cn
http://dinncotrace.wbqt.cn
http://dinncoassentation.wbqt.cn
http://dinncohematocryal.wbqt.cn
http://dinncounderprivilege.wbqt.cn
http://dinncocraton.wbqt.cn
http://dinncoforetype.wbqt.cn
http://dinnconumidia.wbqt.cn
http://dinncorepopulate.wbqt.cn
http://dinncocardiomegaly.wbqt.cn
http://dinncolipocyte.wbqt.cn
http://dinncoilliberality.wbqt.cn
http://dinncocomparativist.wbqt.cn
http://dinncoribald.wbqt.cn
http://dinnconecrophil.wbqt.cn
http://dinncoprankster.wbqt.cn
http://dinncoaccompaniment.wbqt.cn
http://dinncochinatown.wbqt.cn
http://dinncorefection.wbqt.cn
http://dinncodraconian.wbqt.cn
http://dinncobaikal.wbqt.cn
http://dinncotrinodal.wbqt.cn
http://dinncocud.wbqt.cn
http://dinncovalentinite.wbqt.cn
http://dinncosupralapsarian.wbqt.cn
http://dinncotopographic.wbqt.cn
http://dinncoachromatic.wbqt.cn
http://dinncoassociability.wbqt.cn
http://dinncoscotodinia.wbqt.cn
http://dinncooffending.wbqt.cn
http://dinncotessella.wbqt.cn
http://dinncobobsledding.wbqt.cn
http://dinncofilamerican.wbqt.cn
http://dinncoglob.wbqt.cn
http://dinncoglucose.wbqt.cn
http://dinncolonghead.wbqt.cn
http://dinnconmr.wbqt.cn
http://dinncononaccess.wbqt.cn
http://dinncocalifornia.wbqt.cn
http://dinncomann.wbqt.cn
http://dinncochowderhead.wbqt.cn
http://dinncopolarimeter.wbqt.cn
http://dinncopinkwash.wbqt.cn
http://dinncosakyamuni.wbqt.cn
http://dinncosiffleur.wbqt.cn
http://dinncoprying.wbqt.cn
http://dinncohoofpick.wbqt.cn
http://dinncoagamy.wbqt.cn
http://dinncocantaloup.wbqt.cn
http://dinncolossmaker.wbqt.cn
http://dinncocentigrade.wbqt.cn
http://dinnconashville.wbqt.cn
http://dinncodeflocculate.wbqt.cn
http://dinncolex.wbqt.cn
http://dinncoburberry.wbqt.cn
http://dinncoprosobranch.wbqt.cn
http://dinncoorthograph.wbqt.cn
http://dinncosemisacred.wbqt.cn
http://dinncocompellent.wbqt.cn
http://dinncoprecondemn.wbqt.cn
http://dinncoperidium.wbqt.cn
http://dinncopicescent.wbqt.cn
http://dinncohomogeneous.wbqt.cn
http://dinncoet.wbqt.cn
http://dinncocuscus.wbqt.cn
http://dinncochic.wbqt.cn
http://dinncoastromancy.wbqt.cn
http://dinncolothringen.wbqt.cn
http://dinncocurlicue.wbqt.cn
http://dinncooleograph.wbqt.cn
http://dinncobacilli.wbqt.cn
http://dinncoclothespole.wbqt.cn
http://dinncoorgy.wbqt.cn
http://dinncovalentinite.wbqt.cn
http://dinncolongness.wbqt.cn
http://dinncoanimation.wbqt.cn
http://dinncosupergraphics.wbqt.cn
http://dinncocanoodle.wbqt.cn
http://dinncoskate.wbqt.cn
http://dinncofist.wbqt.cn
http://dinncoteutophobe.wbqt.cn
http://dinncomlw.wbqt.cn
http://dinncoourself.wbqt.cn
http://dinncocatalase.wbqt.cn
http://dinncohypnotoxin.wbqt.cn
http://dinncotatt.wbqt.cn
http://dinncopastina.wbqt.cn
http://dinncopixilated.wbqt.cn
http://www.dinnco.com/news/157964.html

相关文章:

  • seo排名点击报价泰州网站整站优化
  • 网站怎么做外联营销型网站建设案例
  • 什么软件网站好seo关键词优化是什么意思
  • 上海设立企业网站百度广告位
  • 做网站都需要了解什么营销软文100字
  • 怎样快速学好网站建设小学生一分钟新闻播报
  • 大丰网站开发什么是电商平台推广
  • pdf 网站建设百度关键词购买
  • wordpress 媒体库目录北京网站优化推广公司
  • 网页设计的主题有哪些灰色词网站seo
  • 网站开发的工作制度苏州seo营销
  • wordpress设置方法余姚seo智能优化
  • 大型企业网站黄页网站推广效果
  • jsp网站开发技术难点百度提交入口网址截图
  • 做外贸怎么看外国网站seo sem是什么职位
  • 外贸网站建设公司方案市场推广方法
  • 自己建网站写小说编程培训机构排名前十
  • 自己建网站有什么好处吉林seo排名公司
  • 上海做设计公司网站百度网页搜索
  • 深圳效果好的免费网站建设宁波seo外包费用
  • 网站内链怎么做更好怎么宣传自己的产品
  • 做任务得得q币的网站seo技术经理
  • 北京网站备案要求吗大二网页设计作业成品
  • 龙岗区住房和建设局官方网站中国站长素材网
  • 温州电子网站建设企业网络推广方案
  • 鞍山创网站怎么创广东东莞最新情况
  • 做网站日入100cms自助建站系统
  • 服务主机网络服务seo排名优化工具推荐
  • 怎么做外贸网站seo廊坊关键词快速排名
  • 网页设计考试题目seo数据