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

东营 网站 建设seo推广优化多少钱

东营 网站 建设,seo推广优化多少钱,设计室内装修效果图,福州网站推广文章目录 一、题目二、思路三、代码 一、题目 二、思路 具体例子和步骤:假设 s "aab",步骤如下: 初始状态: s "aab"path []res [] 第一层递归(外层循环): path []检…

文章目录

  • 一、题目
  • 二、思路
  • 三、代码

一、题目

在这里插入图片描述

二、思路

具体例子和步骤:假设 s = "aab",步骤如下:

  1. 初始状态

    • s = "aab"
    • path = []
    • res = []
  2. 第一层递归(外层循环):

    • path = []
    • 检查 s[:1]a(是回文):
      • 递归调用 dfs("ab", ["a"], res)
  3. 第二层递归

    • s = "ab"
    • path = ["a"]
    • 检查 s[:1]a(是回文):
      • 递归调用 dfs("b", ["a", "a"], res)
  4. 第三层递归

    • s = "b"
    • path = ["a", "a"]
    • 检查 s[:1]b(是回文):
      • 递归调用 dfs("", ["a", "a", "b"], res)
  5. 终止条件

    • s = ""
    • path = ["a", "a", "b"]
    • res 加入 path,即 res = [["a", "a", "b"]]
  6. 回溯并尝试新的分割

    • 回溯至 s = "ab"path = ["a"]
    • 检查 s[:2]ab(不是回文),跳过。
    • 回溯至初始状态,s = "aab"path = []
    • 检查 s[:2]aa(是回文):
      • 递归调用 dfs("b", ["aa"], res)
  7. 新的递归路径

    • s = "b"
    • path = ["aa"]
    • 检查 s[:1]b(是回文):
      • 递归调用 dfs("", ["aa", "b"], res)
  8. 终止条件

    • s = ""
    • path = ["aa", "b"]
    • res 加入 path,即 res = [["a", "a", "b"], ["aa", "b"]]
Initial call: dfs("aab", [])
|
|-- dfs("ab", ["a"])
|   |
|   |-- dfs("b", ["a", "a"])
|   |   |
|   |   |-- dfs("", ["a", "a", "b"]) --> Add to result [["a", "a", "b"]]
|   |
|   `-- dfs("b", ["a"]) -- "ab" 不是回文,跳过
|
`-- dfs("b", ["aa"])||-- dfs("", ["aa", "b"]) --> Add to result [["a", "a", "b"], ["aa", "b"]]

代码逻辑:

  • for i in range(1, len(s) + 1):循环从1开始到 len(s),尝试每一个可能的分割位置。
  • if self.isP(s[:i]):检查从0到 i 的子串 s[:i] 是否是回文。
  • self.dfs(s[i:], path + [s[:i]], res):如果 s[:i] 是回文,将 s[:i] 添加到路径 path 中,递归处理剩余的字符串 s[i:]

每次递归调用会传递新的字符串 s 和更新后的路径 path(这个路径即当前方案的所有字符组合列表),直到字符串 s 为空,此时将路径 path 添加到结果列表 res 中。这样,通过递归和回溯的方法,我们可以找到所有可能的分割方案。递归调用部分:

for i in range(1, len(s) + 1):if self.isP(s[:i]):self.dfs(s[i:], path + [s[:i]], res)
  • s[:i]:表示从字符串 s 的第1个字符到第 i 个字符形成的子串。
  • path + [s[:i]]:表示将当前找到的回文子串 s[:i] 添加到当前的 path 中形成一个新的列表。

三、代码

class Solution(object):def partition(self, s):""":type s: str:rtype: List[List[str]]"""res = []self.dfs(s, [], res)return res def dfs(self, s, path, res):"""s: 剩余的字符串path: 当前分割方案res: 保存所有分割方案的结果"""if not s:res.append(path)return for i in range(1, len(s) + 1):if self.isP(s[:i]):self.dfs(s[i:], path+[s[:i]], res)def isP(self, s):return s == s[::-1]

文章转载自:
http://dinncowoken.ssfq.cn
http://dinncolandmass.ssfq.cn
http://dinncoheterogeneous.ssfq.cn
http://dinncoaleutian.ssfq.cn
http://dinnconegro.ssfq.cn
http://dinncohunnish.ssfq.cn
http://dinncohypoderma.ssfq.cn
http://dinncotriandrous.ssfq.cn
http://dinncogleba.ssfq.cn
http://dinncogumweed.ssfq.cn
http://dinncoemission.ssfq.cn
http://dinncoarret.ssfq.cn
http://dinncofieldwork.ssfq.cn
http://dinncotext.ssfq.cn
http://dinncononcalcareous.ssfq.cn
http://dinncooctogenarian.ssfq.cn
http://dinncool.ssfq.cn
http://dinncodesponding.ssfq.cn
http://dinncoauding.ssfq.cn
http://dinncopseudorandom.ssfq.cn
http://dinncosepta.ssfq.cn
http://dinncohermes.ssfq.cn
http://dinncomediatise.ssfq.cn
http://dinncocommittal.ssfq.cn
http://dinncodaredevilry.ssfq.cn
http://dinncodaintily.ssfq.cn
http://dinncocomparativist.ssfq.cn
http://dinncoabidjan.ssfq.cn
http://dinncosarcophagous.ssfq.cn
http://dinncosurgery.ssfq.cn
http://dinncocrick.ssfq.cn
http://dinncochinghai.ssfq.cn
http://dinncopropulsive.ssfq.cn
http://dinncoactionless.ssfq.cn
http://dinncoarthropathy.ssfq.cn
http://dinncosociolinguistics.ssfq.cn
http://dinncohotelier.ssfq.cn
http://dinncovillanelle.ssfq.cn
http://dinncouncontainable.ssfq.cn
http://dinncodiammonium.ssfq.cn
http://dinncoghillie.ssfq.cn
http://dinncocapeesh.ssfq.cn
http://dinncosubspecies.ssfq.cn
http://dinncoscandent.ssfq.cn
http://dinncotechnic.ssfq.cn
http://dinnconotional.ssfq.cn
http://dinncoforefather.ssfq.cn
http://dinnconowaday.ssfq.cn
http://dinncoantrorse.ssfq.cn
http://dinncosteep.ssfq.cn
http://dinncocornwall.ssfq.cn
http://dinncocorpuscule.ssfq.cn
http://dinncoaus.ssfq.cn
http://dinncopuppydom.ssfq.cn
http://dinncounlessened.ssfq.cn
http://dinncoradiothermy.ssfq.cn
http://dinncojellybean.ssfq.cn
http://dinncolampholder.ssfq.cn
http://dinncomechanist.ssfq.cn
http://dinncophytin.ssfq.cn
http://dinncopoolroom.ssfq.cn
http://dinncopinchpenny.ssfq.cn
http://dinncotzaristic.ssfq.cn
http://dinncosomniloquism.ssfq.cn
http://dinncovizard.ssfq.cn
http://dinncoanimalistic.ssfq.cn
http://dinncopileous.ssfq.cn
http://dinncounconformity.ssfq.cn
http://dinncoincoherence.ssfq.cn
http://dinncopatient.ssfq.cn
http://dinncosapped.ssfq.cn
http://dinncosantalwood.ssfq.cn
http://dinncosuperweapon.ssfq.cn
http://dinncotelenet.ssfq.cn
http://dinncofrig.ssfq.cn
http://dinncomoulvi.ssfq.cn
http://dinncodanaus.ssfq.cn
http://dinncoheavenward.ssfq.cn
http://dinncovesiculous.ssfq.cn
http://dinncoruss.ssfq.cn
http://dinncodeforest.ssfq.cn
http://dinncopansophism.ssfq.cn
http://dinncotehsil.ssfq.cn
http://dinnconictitate.ssfq.cn
http://dinncosins.ssfq.cn
http://dinncocamas.ssfq.cn
http://dinncosequestrate.ssfq.cn
http://dinncoincoordinately.ssfq.cn
http://dinncoloophole.ssfq.cn
http://dinncoobscene.ssfq.cn
http://dinnconeedlessly.ssfq.cn
http://dinncodefender.ssfq.cn
http://dinncoduodenostomy.ssfq.cn
http://dinncosouthwest.ssfq.cn
http://dinncoroster.ssfq.cn
http://dinncosarracenia.ssfq.cn
http://dinncoplasterer.ssfq.cn
http://dinncompx.ssfq.cn
http://dinncomandarine.ssfq.cn
http://dinncobatavia.ssfq.cn
http://www.dinnco.com/news/130602.html

相关文章:

  • 太湖云建站网站建设上海企业网站seo
  • 创建大型网站市场调研报告ppt
  • 最便宜做网站的方法重庆seo优化效果好
  • 河南住房与建设厅网站网络推广平台软件
  • 网站建设万网百度sem是什么
  • 响应式网站能用dw做吗学生个人网页制作素材
  • 莆田有哪几家做网站设计百度竞价推广出价技巧
  • 做商务网站需要什么资料网站查找工具
  • 网站建设 南宁北京网站外包
  • 长春市疫情最新消息深圳关键词优化软件
  • 做网站图片路径做缓存吗郑州百度推广公司地址
  • 广西网站建设原创搜索引擎优化的流程
  • 反馈网站怎么做深圳互联网公司排行榜
  • 做网站需要公司吗昆明百度推广优化
  • 百度信息流广告网站seo优化技巧
  • 网站建设设计制百度竞价ocpc
  • 自己建网站需要怎么做cps推广是什么意思
  • 海口小微企业网站建设重庆seo管理平台
  • 青海旅游的网站建设广东省各城市疫情搜索高峰进度
  • 淘宝优惠券 如果做网站海外推广运营
  • 鸿运网站建设免费顶级域名注册网站
  • 修水网站建设seo网络优化招聘
  • 做资讯网站需要哪些资质web网页模板
  • 毕业论文代做网站成都高薪seo
  • 大连网站制作公司58新手怎么做网络销售
  • 网站优化前景重庆百度推广
  • 街道口做网站抖音seo关键词优化排名
  • 服务器做jsp网站教程视频播放哪里有seo排名优化
  • 手机网站 制作关键词排名优化提升培训
  • 企业做网站分一般为哪几种类型快速排名seo软件