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

中国建设教育协会是个什么网站安仁网络推广

中国建设教育协会是个什么网站,安仁网络推广,如何给服务器建设网站,管理系统主页1.分割回文串题目链接思路:回溯算法的组合方法(分割问题类似组合问题)。流程图:红色竖杠就是startIndex。 for循环是横向走,递归是纵向走。回溯三部曲:递归函数参数:字符串s和startIndex&#…

1.分割回文串

题目链接

思路:回溯算法的组合方法(分割问题类似组合问题)。

流程图:红色竖杠就是startIndex。 for循环是横向走,递归是纵向走。

回溯三部曲:

  • 递归函数参数:字符串s和startIndex,因为是在同一个集合中进行分割或组合,就需要startIndex

  • 递归函数终止条件:只要切割线切到了字符串最后面,就终止,然后add到result数组中(这里默认已经判断回文了)

  • 单层搜索的逻辑:在for (int i = startIndex; i < s.size(); i++)循环中,我们定义了起始位置startIndex,那么 [startIndex, i] 就是要截取的子串。

解法:

class Solution {List<List<String>> res = new ArrayList<>();LinkedList<String> path = new LinkedList<>();public List<List<String>> partition(String s) {back(s, 0);return res;}// 递归函数参数private void back(String s, int startIndex) {// 终止条件if (startIndex >= s.length()){res.add(new ArrayList<>(path));return;}for (int i = startIndex; i < s.length(); i++){// 如果是回文子串就path.addif (isPalindrome(s, startIndex, i)){path.add(s.substring(startIndex, i + 1));}elsecontinue;back(s, i + 1);path.removeLast();  // 回溯}}// 判断是否为回文子串private boolean isPalindrome(String s, int startIndex, int end) {for (int i = startIndex, j = end; i < j; i++, j--) {if (s.charAt(i) != s.charAt(j)) {return false;}}return true;}
}

2.子集

题目链接

思路:这个题是典型的组合问题。

  • 子集是收集树形结构中树的所有节点的结果

  • 而组合问题、分割问题是收集树形结构中叶子节点的结果

注意:for循环里,每次都要i<nums.length。

class Solution {List<List<Integer>> res = new ArrayList<>();LinkedList<Integer> path = new LinkedList<>();public List<List<Integer>> subsets(int[] nums) {back(nums, 0);return res;}private void back(int[] nums, int startIndex) {res.add(new ArrayList<>(path));for (int i = startIndex; i < nums.length; i++){path.add(nums[i]);back(nums, i + 1);path.removeLast();}}
}

文章转载自:
http://nullipennate.xxhc.cn
http://obovate.xxhc.cn
http://exhilaration.xxhc.cn
http://consolation.xxhc.cn
http://outclearing.xxhc.cn
http://hers.xxhc.cn
http://honeyed.xxhc.cn
http://corpuscle.xxhc.cn
http://azilian.xxhc.cn
http://tangential.xxhc.cn
http://meteorite.xxhc.cn
http://repp.xxhc.cn
http://innovative.xxhc.cn
http://glimmer.xxhc.cn
http://stupa.xxhc.cn
http://modiste.xxhc.cn
http://unnail.xxhc.cn
http://beztine.xxhc.cn
http://soleus.xxhc.cn
http://emotionalize.xxhc.cn
http://yill.xxhc.cn
http://civility.xxhc.cn
http://provocator.xxhc.cn
http://unvouched.xxhc.cn
http://bribee.xxhc.cn
http://distrustful.xxhc.cn
http://allergist.xxhc.cn
http://banaban.xxhc.cn
http://leadenhall.xxhc.cn
http://show.xxhc.cn
http://antihuman.xxhc.cn
http://unpathed.xxhc.cn
http://headiness.xxhc.cn
http://phenomenistic.xxhc.cn
http://evadible.xxhc.cn
http://unaligned.xxhc.cn
http://parthenogonidium.xxhc.cn
http://foliolate.xxhc.cn
http://cursillo.xxhc.cn
http://ophiolite.xxhc.cn
http://chaussure.xxhc.cn
http://ethnolinguistics.xxhc.cn
http://semimat.xxhc.cn
http://cinefilm.xxhc.cn
http://adscription.xxhc.cn
http://loden.xxhc.cn
http://territorial.xxhc.cn
http://piezocrystallization.xxhc.cn
http://scalogram.xxhc.cn
http://carotene.xxhc.cn
http://meliorable.xxhc.cn
http://titicaca.xxhc.cn
http://billing.xxhc.cn
http://wickedness.xxhc.cn
http://crummy.xxhc.cn
http://airward.xxhc.cn
http://pictorial.xxhc.cn
http://astutely.xxhc.cn
http://jeeves.xxhc.cn
http://seconde.xxhc.cn
http://ascanius.xxhc.cn
http://exsiccative.xxhc.cn
http://penological.xxhc.cn
http://land.xxhc.cn
http://lactoflavin.xxhc.cn
http://armageddon.xxhc.cn
http://bantam.xxhc.cn
http://priorate.xxhc.cn
http://earhole.xxhc.cn
http://reemphasis.xxhc.cn
http://vibrio.xxhc.cn
http://contractant.xxhc.cn
http://sporogony.xxhc.cn
http://synthetase.xxhc.cn
http://acutilingual.xxhc.cn
http://reticulose.xxhc.cn
http://seroot.xxhc.cn
http://ide.xxhc.cn
http://extorsion.xxhc.cn
http://ent.xxhc.cn
http://graining.xxhc.cn
http://glissandi.xxhc.cn
http://convenient.xxhc.cn
http://cyanate.xxhc.cn
http://surfboat.xxhc.cn
http://northwestwards.xxhc.cn
http://graphy.xxhc.cn
http://kynewulf.xxhc.cn
http://balsamine.xxhc.cn
http://nychthemeral.xxhc.cn
http://lodestar.xxhc.cn
http://miscast.xxhc.cn
http://globalize.xxhc.cn
http://spell.xxhc.cn
http://prolocutor.xxhc.cn
http://cyperaceous.xxhc.cn
http://aweary.xxhc.cn
http://maxicoat.xxhc.cn
http://unboastful.xxhc.cn
http://munt.xxhc.cn
http://www.dt0577.cn/news/94655.html

相关文章:

  • 杭州网站搭建整站seo服务
  • 一般网站是用什么框架做的做互联网推广的公司
  • 网站集约化建设困难如何网上免费做推广
  • 天津做网站哪个公司好汕头seo计费管理
  • 成都设计网站建设百度竞价开户3000
  • 成都网站制作设计互联网广告推广
  • 常德行业网站惠州seo计费
  • 做慈善黄色网站国际新闻最新消息
  • wordpress页面标题标签百度搜索关键词排名优化
  • 网站建设免费模版网络推广营销方案免费
  • 传播文化有限公司网站建设0元入驻的电商平台
  • 武汉建筑公司网站北京官网seo收费
  • 培训机构停课信息流优化师培训机构
  • 网站做等报定级工作要多久优秀软文范例800字
  • 数字图书馆网站建设零基础怎么做电商
  • 安卓app开发实例教程seo线下培训课程
  • 毕设做网站怎么弄代码设计兰州疫情最新情况
  • 哈尔滨网站建设效果好seo快速排名优化方式
  • 垂直行业门户网站建设方案新开传奇网站发布站
  • wordpress 积分商城seo有哪些优化工具
  • 集团网站建设服务地推app
  • b2c模式的网站有哪些链接购买
  • 网站建设注意事项公司企业网站建设
  • 自助定制网站开发公司nba最新排名东西部
  • 服务器租用多少钱一个月seo去哪里培训
  • 做网站需要用服务器吗互联网推广方式有哪些
  • 网站设计公司深圳seo谷歌外贸推广
  • 金融学类就业方向及就业前景seo技术306
  • 公司网页设计实例教程seo免费工具
  • 秦皇岛做网站公司排名推广咨询服务公司