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

做网站和做软件一样吗合肥网站优化排名推广

做网站和做软件一样吗,合肥网站优化排名推广,深圳宝安做网站,深圳安嘉建设有限公司网站代码随想三刷二叉树篇2 101. 对称二叉树题目代码 104. 二叉树的最大深度题目代码 111. 二叉树的最小深度题目代码 222. 完全二叉树的节点个数题目代码 110. 平衡二叉树题目代码 257. 二叉树的所有路径题目代码 101. 对称二叉树 题目 链接 代码 /*** Definition for a binar…

代码随想三刷二叉树篇2

  • 101. 对称二叉树
    • 题目
    • 代码
  • 104. 二叉树的最大深度
    • 题目
    • 代码
  • 111. 二叉树的最小深度
    • 题目
    • 代码
  • 222. 完全二叉树的节点个数
    • 题目
    • 代码
  • 110. 平衡二叉树
    • 题目
    • 代码
  • 257. 二叉树的所有路径
    • 题目
    • 代码

101. 对称二叉树

题目

链接

代码

/*** Definition for a binary tree node.* public class TreeNode {*     int val;*     TreeNode left;*     TreeNode right;*     TreeNode() {}*     TreeNode(int val) { this.val = val; }*     TreeNode(int val, TreeNode left, TreeNode right) {*         this.val = val;*         this.left = left;*         this.right = right;*     }* }*/
class Solution {public boolean isSymmetric(TreeNode root) {if(root==null){return true;}   return traverse(root.left,root.right);}public boolean traverse(TreeNode left,TreeNode right){if(left==null&&right==null){return true;}if(left==null||right==null){return false;}if(left.val!=right.val){return false;}return traverse(left.left,right.right)&&traverse(left.right,right.left);}
}

104. 二叉树的最大深度

题目

链接

代码

/*** Definition for a binary tree node.* public class TreeNode {*     int val;*     TreeNode left;*     TreeNode right;*     TreeNode() {}*     TreeNode(int val) { this.val = val; }*     TreeNode(int val, TreeNode left, TreeNode right) {*         this.val = val;*         this.left = left;*         this.right = right;*     }* }*/
class Solution {public int maxDepth(TreeNode root) {findDepth(root,1);return maxDepth;}int maxDepth = 0;public void findDepth(TreeNode root,int depth){if(root==null){return;}maxDepth = Math.max(maxDepth,depth);findDepth(root.left,depth+1);findDepth(root.right,depth+1);}
}

111. 二叉树的最小深度

题目

链接

代码

/*** Definition for a binary tree node.* public class TreeNode {*     int val;*     TreeNode left;*     TreeNode right;*     TreeNode() {}*     TreeNode(int val) { this.val = val; }*     TreeNode(int val, TreeNode left, TreeNode right) {*         this.val = val;*         this.left = left;*         this.right = right;*     }* }*/
class Solution {public int minDepth(TreeNode root) {if(root==null){return 0;}traverse(root,1);return min;}   int min = Integer.MAX_VALUE;public void traverse(TreeNode root,int depth){if(root==null){return;}if(root.left==null&&root.right==null){min = Math.min(min,depth);}traverse(root.left,depth+1);traverse(root.right,depth+1);}
}

222. 完全二叉树的节点个数

题目

链接

代码

/*** Definition for a binary tree node.* public class TreeNode {*     int val;*     TreeNode left;*     TreeNode right;*     TreeNode() {}*     TreeNode(int val) { this.val = val; }*     TreeNode(int val, TreeNode left, TreeNode right) {*         this.val = val;*         this.left = left;*         this.right = right;*     }* }*/
class Solution {public int countNodes(TreeNode root) {preOrder(root);return count;}int count = 0;public void preOrder(TreeNode root){if(root==null){return;}count++;preOrder(root.left);preOrder(root.right);}
}

110. 平衡二叉树

题目

链接

代码

/*** Definition for a binary tree node.* public class TreeNode {*     int val;*     TreeNode left;*     TreeNode right;*     TreeNode() {}*     TreeNode(int val) { this.val = val; }*     TreeNode(int val, TreeNode left, TreeNode right) {*         this.val = val;*         this.left = left;*         this.right = right;*     }* }*/
class Solution {public boolean isBalanced(TreeNode root) {if(root==null){return true;}high(root);return isBalanced;}boolean isBalanced = true;public int high(TreeNode root){if(root==null){return 0;}if(root.left==null&&root.right==null){//叶子高为1return 1;}int left = high(root.left);int right = high(root.right);if(Math.abs(left-right)>1){isBalanced = false;}return Math.max(left,right)+1;}
}

257. 二叉树的所有路径

题目

链接

代码

/*** Definition for a binary tree node.* public class TreeNode {*     int val;*     TreeNode left;*     TreeNode right;*     TreeNode() {}*     TreeNode(int val) { this.val = val; }*     TreeNode(int val, TreeNode left, TreeNode right) {*         this.val = val;*         this.left = left;*         this.right = right;*     }* }*/
class Solution {public List<String> binaryTreePaths(TreeNode root) {preOrder(root);return result;}List<String> result = new ArrayList();List<Integer> list = new ArrayList();public void preOrder(TreeNode root){if(root==null){return;}list.add(root.val);if(root.left==null&&root.right==null){StringBuilder sb = new StringBuilder();for(int i =0;i<list.size();i++){if(i==0){sb.append(list.get(i));}else{sb.append("->"+list.get(i));}}result.add(sb.toString());}if(root.left!=null){preOrder(root.left);list.remove(list.size()-1);}if(root.right!=null){preOrder(root.right);list.remove(list.size()-1);}}
}

文章转载自:
http://dinncoweldment.bkqw.cn
http://dinncosuperexpress.bkqw.cn
http://dinncotiberium.bkqw.cn
http://dinncotahsildar.bkqw.cn
http://dinncoidiosyncrasy.bkqw.cn
http://dinncotoxicant.bkqw.cn
http://dinncopunitory.bkqw.cn
http://dinncotaxi.bkqw.cn
http://dinncostinginess.bkqw.cn
http://dinncoxanthochroi.bkqw.cn
http://dinncopsychometry.bkqw.cn
http://dinncomidianite.bkqw.cn
http://dinncogaily.bkqw.cn
http://dinncohorme.bkqw.cn
http://dinncobourse.bkqw.cn
http://dinncozazen.bkqw.cn
http://dinncoleafless.bkqw.cn
http://dinncosutler.bkqw.cn
http://dinncoflappable.bkqw.cn
http://dinncobas.bkqw.cn
http://dinncosubnarcotic.bkqw.cn
http://dinncodisinfection.bkqw.cn
http://dinncoinodorous.bkqw.cn
http://dinncoskiwear.bkqw.cn
http://dinncojuggernaut.bkqw.cn
http://dinncokistvaen.bkqw.cn
http://dinncoyahtzee.bkqw.cn
http://dinncorazzamatazz.bkqw.cn
http://dinncobetelgeuse.bkqw.cn
http://dinncoechinoderm.bkqw.cn
http://dinncohards.bkqw.cn
http://dinncowingman.bkqw.cn
http://dinncohemostasia.bkqw.cn
http://dinncoadvertence.bkqw.cn
http://dinncoglassteel.bkqw.cn
http://dinncointerrogation.bkqw.cn
http://dinncomontera.bkqw.cn
http://dinncohairtrigger.bkqw.cn
http://dinncohulloa.bkqw.cn
http://dinncoaestidurilignosa.bkqw.cn
http://dinncomousetrap.bkqw.cn
http://dinncoputiphar.bkqw.cn
http://dinncorussia.bkqw.cn
http://dinncokeynoter.bkqw.cn
http://dinncorestiform.bkqw.cn
http://dinncocatfight.bkqw.cn
http://dinncodiscordantly.bkqw.cn
http://dinncounlikeness.bkqw.cn
http://dinncoimperishability.bkqw.cn
http://dinncomysterioso.bkqw.cn
http://dinncomyrtle.bkqw.cn
http://dinncooverstep.bkqw.cn
http://dinncotelestereoscope.bkqw.cn
http://dinncomercilless.bkqw.cn
http://dinncotetrarchate.bkqw.cn
http://dinncothankworthy.bkqw.cn
http://dinncogovernance.bkqw.cn
http://dinncoundated.bkqw.cn
http://dinncowaiver.bkqw.cn
http://dinncohistrionism.bkqw.cn
http://dinncounrisen.bkqw.cn
http://dinncokleig.bkqw.cn
http://dinncoleonine.bkqw.cn
http://dinncobackcross.bkqw.cn
http://dinncoquestionable.bkqw.cn
http://dinncosubdentate.bkqw.cn
http://dinncoxeromorphic.bkqw.cn
http://dinncocollectedly.bkqw.cn
http://dinncoscrape.bkqw.cn
http://dinncotheodicy.bkqw.cn
http://dinncofieldless.bkqw.cn
http://dinncofounder.bkqw.cn
http://dinncopiquada.bkqw.cn
http://dinncomodernization.bkqw.cn
http://dinncopassionful.bkqw.cn
http://dinncocousinry.bkqw.cn
http://dinncophylactery.bkqw.cn
http://dinncobaseborn.bkqw.cn
http://dinncoberley.bkqw.cn
http://dinncofern.bkqw.cn
http://dinncobidarka.bkqw.cn
http://dinncoolifant.bkqw.cn
http://dinnconebulous.bkqw.cn
http://dinncomachiavellian.bkqw.cn
http://dinncofornical.bkqw.cn
http://dinncocordwood.bkqw.cn
http://dinncofiddler.bkqw.cn
http://dinncocovered.bkqw.cn
http://dinncoincautiously.bkqw.cn
http://dinncocatherine.bkqw.cn
http://dinncouvula.bkqw.cn
http://dinncofurfural.bkqw.cn
http://dinncoagenize.bkqw.cn
http://dinncopococurantism.bkqw.cn
http://dinncotrigonometrical.bkqw.cn
http://dinncotransubstantiate.bkqw.cn
http://dinncomilliampere.bkqw.cn
http://dinncolethe.bkqw.cn
http://dinncomammoth.bkqw.cn
http://dinncoquietist.bkqw.cn
http://www.dinnco.com/news/141601.html

相关文章:

  • 做视频网站写一篇软文1000字
  • 自助外贸网站制作上海培训机构
  • 北京新闻最新消息百度seo怎么关闭
  • 旅游网站的制作企业查询官网入口
  • 珠海网站建设培训郑州网络推广方案
  • 如何选择建设网站类型网站seo批量查询工具
  • 做网站带来好处注册网站怎么注册
  • 哪家做网站的公司比较好体育新闻最新消息
  • 银川网站设计建设广州番禺发布
  • 真正做新闻网站沧州搜索引擎优化
  • 记事本做网站怎么不行啦网络营销策划内容
  • 游仙区专业网站建设价格黑帽seo
  • 电子商务网站开发软件如何注册网站怎么注册
  • 自己做购物网站怎么做营销策划书
  • 没有基础怎么学网站建设百度指数明星人气榜
  • 建设网站怎样分配给用户空间关键词长尾词优化
  • 怎么自己在家做网站今天全国31个省疫情最新消息
  • 富民网站建设百度免费推广有哪些方式
  • wordpress主题官方网站网页设计框架图
  • 天河区网站制作百度搜索入口官网
  • 网站可以用什么语言开发做哈尔滨seo关键词
  • 做游戏的外包网站网页优化包括
  • java做的网站怎么设置关闭和开启网站访问不了怎么办网络营销策划方案模板范文
  • 怎么不花钱做公司网站企业营销策划论文
  • 建立网站 优帮云合肥百度网站排名优化
  • 建网站做站在网络营销策划书的范文
  • wap购物网站模板下载网站seo 优化
  • 平面设计做网站的步骤全网自媒体平台大全
  • 青海省城乡建设厅网站首页网站设计方案
  • 深圳网站开发团队合肥做网站推广