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

著名的网站制作公司游戏优化是什么意思

著名的网站制作公司,游戏优化是什么意思,做赌博网站刷单违法吗,自己做的网站出现iis7代码随想录算法刷题训练营day16:LeetCode(104)二叉树的最大深度 、LeetCode(559)n叉树的最大深度、LeetCode(111)二叉树的最小深度、LeetCode(222)完全二叉树的节点个数 LeetCode(104)二叉树的最大深度 题目 代码 /*** Definition for a binary tree node.* publ…

代码随想录算法刷题训练营day16:LeetCode(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(root==null){return 0;}//不为空,先求左子树的高度int heightLeft=maxDepth(root.left);//再求右子树的高度int heightRight=maxDepth(root.right);int heightRoot;//定义根节点的高度if(heightLeft>heightRight){heightRoot=heightLeft+1;}else{heightRoot=heightRight+1;}return heightRoot;}
}

LeetCode(559)n叉树的最大深度
题目
在这里插入图片描述
代码

// @lc code=start
/*
// Definition for a Node.
class Node {public int val;public List<Node> children;public Node() {}public Node(int _val) {val = _val;}public Node(int _val, List<Node> _children) {val = _val;children = _children;}
};
*/class Solution {public int maxDepth(Node root) {//同样用后续遍历去做if(root==null){return 0;}int maxheight=0;List<Node> childrens=root.children;//遍历集合for (Node children : childrens) {int tempHeight=maxDepth(children);if(tempHeight>maxheight){maxheight=tempHeight;//找出所有子树中节点最高的树}    }return maxheight+1;    }
}

LeetCode(111)二叉树的最小深度
题目
在这里插入图片描述

代码

// @lc code=start
/*** 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;}int rootHeight;//同样用后续遍历去做if(root.left==null){rootHeight=minDepth(root.right)+1;return rootHeight;}if(root.right==null){rootHeight=minDepth(root.left)+1;return rootHeight;}int leftHeight=minDepth(root.left);int rightHeight=minDepth(root.right);if(leftHeight<rightHeight){rootHeight=leftHeight+1;}else{rootHeight=rightHeight+1;}return rootHeight;}

LeetCode(222)完全二叉树的节点个数
题目
在这里插入图片描述
代码

// @lc code=start
/*** 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 number=0;public int countNodes(TreeNode root) {if(root==null){return 0;}int leftCountNodes=countNodes(root.left);int rightCountNodes=countNodes(root.right);int countSum=leftCountNodes+rightCountNodes+1;//常规遍历方法return countSum;}
}
http://www.dinnco.com/news/23704.html

相关文章:

  • 网络运营主要工作内容seo网站培训优化怎么做
  • 微信小程序制作商连云港网站seo
  • 泉州做网站工作室市场调研报告3000字范文
  • 网页制作专业选择seo单词优化
  • 下关汇做网站的公司运营网站是什么意思
  • 非小号是根据国外哪个网站做的seo就业前景
  • c 手机网站开发百度论坛首页
  • 佳木斯做网站公司网站优化
  • 福建建设银行官方网站小程序开发文档
  • 自己做的网站响应速度慢软文范例大全1000字
  • 设计网站猪八戒关键词首页排名代做
  • 创造与魔法官方网站一起做喜欢的事短视频seo营销系统
  • 网站关键词排名下降项目网
  • 国家卫生计生委能力建设和继续教育中心网站推广优化网站排名教程
  • 重庆工程造价信息官网成都seo技术经理
  • 怎样新建网站郑州网站设计
  • 新建的网站 找不到了百度指数教程
  • 惠东县住房和城乡规划建设局网站百度上搜索关键词如何在首页
  • 重庆博达建设集团股份有限公司网站百度提交网站
  • 广州做网站公司哪家好网络营销能干什么工作
  • 福州seo推广优化泉州百度关键词优化
  • 做网站怎么宣传青岛网站seo公司
  • 网站上的在线客服怎么做的百度的特点和优势
  • 长沙市城市建设档案馆网站希爱力双效片的作用与功效
  • wordpress超链接无下划线汕头网站优化
  • 英德网站seo九幺seo工具
  • python做网站毕业设计chrome官方下载
  • 手机网站需要域名吗推广策划方案范文
  • 网站建设的资料的准备aso优化师
  • web网站开发公司电商培训内容有哪些