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

门户网站建设服务收费工业设计 做自己的网站 知乎

门户网站建设服务收费,工业设计 做自己的网站 知乎,做网站赚钱平台,建设个直播网站要多少钱代码随想录算法刷题训练营day16#xff1a;LeetCode(104)二叉树的最大深度 、LeetCode(559)n叉树的最大深度、LeetCode(111)二叉树的最小深度、LeetCode(222)完全二叉树的节点个数 LeetCode(104)二叉树的最大深度 题目 代码 /*** Definition for a binary tree node.* publ…代码随想录算法刷题训练营day16LeetCode(104)二叉树的最大深度 、LeetCode(559)n叉树的最大深度、LeetCode(111)二叉树的最小深度、LeetCode(222)完全二叉树的节点个数 LeetCode(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) {//通过递归去做---传入的是根节点可以求根节点的高度来代替深度//先求左右子树的高度1即为根节点的高度----确定遍历方式为左右根//采用递归先判断终止条件if(rootnull){return 0;}//不为空先求左子树的高度int heightLeftmaxDepth(root.left);//再求右子树的高度int heightRightmaxDepth(root.right);int heightRoot;//定义根节点的高度if(heightLeftheightRight){heightRootheightLeft1;}else{heightRootheightRight1;}return heightRoot;} }LeetCode(559)n叉树的最大深度 题目 代码 // lc codestart /* // Definition for a Node. class Node {public int val;public ListNode children;public Node() {}public Node(int _val) {val _val;}public Node(int _val, ListNode _children) {val _val;children _children;} }; */class Solution {public int maxDepth(Node root) {//同样用后续遍历去做if(rootnull){return 0;}int maxheight0;ListNode childrensroot.children;//遍历集合for (Node children : childrens) {int tempHeightmaxDepth(children);if(tempHeightmaxheight){maxheighttempHeight;//找出所有子树中节点最高的树} }return maxheight1; } }LeetCode(111)二叉树的最小深度 题目 代码 // lc codestart /*** 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(rootnull){return 0;}int rootHeight;//同样用后续遍历去做if(root.leftnull){rootHeightminDepth(root.right)1;return rootHeight;}if(root.rightnull){rootHeightminDepth(root.left)1;return rootHeight;}int leftHeightminDepth(root.left);int rightHeightminDepth(root.right);if(leftHeightrightHeight){rootHeightleftHeight1;}else{rootHeightrightHeight1;}return rootHeight;}LeetCode(222)完全二叉树的节点个数 题目 代码 // lc codestart /*** 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 {int number0;public int countNodes(TreeNode root) {if(rootnull){return 0;}int leftCountNodescountNodes(root.left);int rightCountNodescountNodes(root.right);int countSumleftCountNodesrightCountNodes1;//常规遍历方法return countSum;} }
http://www.tj-hxxt.cn/news/132428.html

相关文章:

  • 信息产业部icp备案中心网站新乡商城网站建设哪家好
  • 合肥的网站建设公司哪家好下述不属于网页制作工具
  • 仪器仪表网站制作徐州优化网站建设
  • 单页网站网址建筑必看六个网站
  • 霸州网站开发网站建设中英语如何说
  • 凯里网站建设哪家专业有个找人做任务赚返佣的网站
  • 设计素材网站哪个最好用wordpress后台二次开发
  • 设计得好的美食网站wordpress电影分享
  • jsp网站开发实例教程网络管理系统密码
  • 做那种事情的网站青岛科技网站建设
  • 学校网站建设成功织梦网站图片代码
  • 移动互联与网站开发编辑网站教程
  • 公章电子版在线制作网站四川建设工程信息网官网
  • 性价比最高网站建设电话正规的网站建设公
  • 网站 设计 工具网站建设中英版
  • 中恒建设职业技术培训学校网站网络营销首先要做什么
  • 学ui设计网站微转app是用网站做的吗
  • 大学生网站建设例题答案设计好的网站
  • 网站排名优化化快排优化广告设计有哪些
  • 数据库网站建设教程免费域名备案
  • 大型网站过程网站初期内容
  • 海南省建设网站首页网站流量的重要性
  • 做网站项目主要技术北京市网上服务平台登录
  • 西安百度网站快速优化网站用小程序
  • 网站seo关键词排名优化wordpress 四亩
  • 教你做文案的网站推荐网站设计资源
  • 青州网站建设青州上海天华建筑设计有限公司合肥分公司
  • 免费做苗木网站软件开发项目经理职责
  • designer怎么做网站企业邮箱与个人邮箱有什么区别
  • wordpress 电影模版有谁知道网站优化怎么做