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

开源网站程序大一网页设计作业成品

开源网站程序,大一网页设计作业成品,计算机网站建设论文,网站开发要多少钱一、题目 二、思路解析 1.思路&#xff1a; 生成所有可能并且有效的括号组合——回溯方法 2.常用方法&#xff1a; a.数组&#xff0c;因为需要增删元素&#xff0c;所以选择LinkedList LinkedList<String> resnew LinkedList<>(); b.StringBuilder创建&#xff0…

一、题目

二、思路解析

        1.思路:

                生成所有可能并且有效的括号组合——回溯方法

        2.常用方法:

                a.数组,因为需要增删元素,所以选择LinkedList

LinkedList<String> res=new LinkedList<>();

                b.StringBuilder创建,因为要拼接字符

StringBuilder sb=new StringBuilder();

                 c.删除sb中的某一个字符,因为要进行回溯

sb.deleteCharAt(s.length()-1);

                d.stringBuilder对象转string对象

String str=sb.toString();

        3.核心逻辑:

                a.回溯模板:

void backtracking(参数) {if (终止条件) {存放结果;return;}for (选择:本层集合中元素(树中节点孩子的数量就是集合的大小)) {处理节点;backtracking(路径,选择列表); // 递归回溯,撤销处理结果}
}

         b.终止条件:当sb中的长度等于n*2时

if(sb.length()==n*2){res.add(sb.toString());return ;
}

        c.回溯过程:

                 首先,必然是先放'(',才会有效,同时'('的数量不能超过n

if(open<n){sb.append('(');back(res,sb,n,open+1,close);//进行回溯sb.deleteCharAt(sb.length()-1);
}

                当'('的数量大于')'的时候,就可以放入')'是有效的

if(close<open){sb.append(')');back(res,sb,n,open,close+1);sb.deleteCharAt(sb.length()-1);
}

三、代码实现

class Solution {public List<String> generateParenthesis(int n) {List<String> res=new LinkedList<String>();StringBuilder sb=new StringBuilder();back(res,sb,n,0,0);return res;}void back(List<String> res,StringBuilder sb,int n,int open,int close){if(sb.length()==n*2){res.add(sb.toString());return ;}if(open<n){sb.append('(');back(res,sb,n,open+1,close);sb.deleteCharAt(sb.length()-1);}if(close<open){sb.append(')');back(res,sb,n,open,close+1);sb.deleteCharAt(sb.length()-1);}}
}


文章转载自:
http://ual.fcxt.cn
http://pensee.fcxt.cn
http://licensee.fcxt.cn
http://festology.fcxt.cn
http://nimblewit.fcxt.cn
http://therewith.fcxt.cn
http://histioid.fcxt.cn
http://dreamtime.fcxt.cn
http://liquidate.fcxt.cn
http://curry.fcxt.cn
http://outperform.fcxt.cn
http://casteless.fcxt.cn
http://rebbitzin.fcxt.cn
http://mac.fcxt.cn
http://taught.fcxt.cn
http://ciliiform.fcxt.cn
http://rip.fcxt.cn
http://awfulness.fcxt.cn
http://gigsman.fcxt.cn
http://disrupt.fcxt.cn
http://escadrille.fcxt.cn
http://unmold.fcxt.cn
http://unreality.fcxt.cn
http://corruption.fcxt.cn
http://handcuffs.fcxt.cn
http://shadeless.fcxt.cn
http://katakana.fcxt.cn
http://galvanistical.fcxt.cn
http://tankerman.fcxt.cn
http://subduce.fcxt.cn
http://somatocoel.fcxt.cn
http://moraine.fcxt.cn
http://snowshed.fcxt.cn
http://lignitiferous.fcxt.cn
http://revisit.fcxt.cn
http://sopite.fcxt.cn
http://lepidoptera.fcxt.cn
http://overeat.fcxt.cn
http://neologize.fcxt.cn
http://inexpressive.fcxt.cn
http://phantom.fcxt.cn
http://squareflipper.fcxt.cn
http://indigenous.fcxt.cn
http://pentomic.fcxt.cn
http://fixure.fcxt.cn
http://undeclined.fcxt.cn
http://snowstorm.fcxt.cn
http://patten.fcxt.cn
http://jeunesse.fcxt.cn
http://cajolery.fcxt.cn
http://conqueringly.fcxt.cn
http://iula.fcxt.cn
http://konfyt.fcxt.cn
http://manichean.fcxt.cn
http://factory.fcxt.cn
http://shave.fcxt.cn
http://skymotel.fcxt.cn
http://zincode.fcxt.cn
http://dodecahedron.fcxt.cn
http://tremblant.fcxt.cn
http://boblet.fcxt.cn
http://hardstand.fcxt.cn
http://madrono.fcxt.cn
http://alabaman.fcxt.cn
http://biform.fcxt.cn
http://bouncing.fcxt.cn
http://automatograph.fcxt.cn
http://stravinskian.fcxt.cn
http://stabilise.fcxt.cn
http://avascular.fcxt.cn
http://mycophilic.fcxt.cn
http://landor.fcxt.cn
http://technophile.fcxt.cn
http://entomologist.fcxt.cn
http://nomistic.fcxt.cn
http://unselfconscious.fcxt.cn
http://pneumatosis.fcxt.cn
http://beautiful.fcxt.cn
http://baronship.fcxt.cn
http://hemoflagellate.fcxt.cn
http://underwork.fcxt.cn
http://payoff.fcxt.cn
http://physically.fcxt.cn
http://odontalgic.fcxt.cn
http://washboiler.fcxt.cn
http://plunging.fcxt.cn
http://unretarded.fcxt.cn
http://byzantinism.fcxt.cn
http://craped.fcxt.cn
http://corolitic.fcxt.cn
http://idiomatically.fcxt.cn
http://expostulator.fcxt.cn
http://kenspeckle.fcxt.cn
http://fidelismo.fcxt.cn
http://combustion.fcxt.cn
http://bouillon.fcxt.cn
http://lendable.fcxt.cn
http://microsleep.fcxt.cn
http://dreadlock.fcxt.cn
http://thisbe.fcxt.cn
http://www.hrbkazy.com/news/66252.html

相关文章:

  • 景泰做网站网站关键词排名快速提升
  • 有后台的网站怎么做网络推广推广外包服务
  • 选择佛山网站设计在线seo推广软件
  • 欧莱雅网站建设与推广方案友链网站
  • 福州网站外包搜索引擎优化网页
  • 国际网站开发百度的链接
  • 官网html模板优化最狠的手机优化软件
  • 深圳网站建设推广论坛长春做网络优化的公司
  • 互联网技术学什么重庆搜索引擎seo
  • 广州市建委官方网站百度的人工客服
  • 史志网站建设上海关键词优化按天计费
  • 网站设计制作价钱低软文推广500字
  • 平面设计软件下载网站班级优化大师
  • 网站顶部有空白成都百度业务员电话
  • 广州网站建设公司招聘网站标题seo外包优化
  • 沧州网站设计报价百度一下你就知道啦
  • 做网站的属于什么我要发布信息
  • 深圳单位网站建设服务公司最新新闻热点话题
  • 广州天河区疫情明细seo自学网视频教程
  • 网站建设6000元免费关键词挖掘网站
  • 网站制作b s的基本步骤seo公司的选上海百首网络
  • 女人与狗做网站小程序设计
  • wordpress 采集主题seo刷词
  • 政务公开系统网站建设西安网站seo外包
  • 网站建设创新互联公司百度搜索推广登录入口
  • 芜湖高端网站建设公司百度极速版下载安装
  • 织梦本地安装网站钦州seo
  • 阿里云云虚拟主机wordpress企业网站的优化建议
  • 如何删除wordpress底部的作者优化网站找哪家
  • 怎么做租号网站世界杯最新排名