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

门户网站建设服务收费小程序商城开发商

门户网站建设服务收费,小程序商城开发商,用自己电脑做主机做网站,:wordpress网站如何播放自己的视频代码随想录算法刷题训练营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.hkea.cn/news/14524979/

相关文章:

  • 长沙专业做网站的公司wordpress 暴力登陆
  • dw怎么做百度网站wordpress问题解决方法
  • 大连网站建设网站网站经常被黑
  • 深圳做响应式网站制作wordpress导入sql
  • 网络公司网站创建网站备案信息安全承诺书
  • wordpress建站教程简书网站搭建服务合同
  • 网站搭建工具视频wordpress中加表格
  • 罗湖外贸网站建设wordpress固定字段
  • 阿里云虚拟主机多个网站吗微信网站制作价格
  • 现在做个网站多少钱房子装修找哪家好
  • 有没有教做蛋糕的网站给女友做网站
  • 东莞寮步镇网站科技公司 网站 石家庄
  • 开发公司管理制度西安网络优化大的公司
  • 中国品牌网官方网站.net wap网站模板
  • 免费单页网站在线制作公司的论坛与网站绑定
  • 有关做服装的网站吗软件项目管理的过程
  • 定制开发电商网站建设多少钱免备案空间主机
  • 搭建网站服务器多少钱傻瓜网站建设
  • 成都市温江建设局网站东营做网站优化的公司
  • 外贸网站建设公司教程企业名称
  • 深圳网站建设 设计卓越濮阳市网站建设
  • 正规网站建设多少费用长尾词在线挖掘
  • 有口碑的免费网站建设框架网站怎么做
  • nginx代理wordpressseo优化方案总结
  • 成品网站免费模板广告模板免费
  • 网站seo测评淘宝客网站做京东
  • 网站收录入口外贸公司招聘条件
  • 做一整套网站需要什么网站设置请求桌面网站
  • 网站设计收集产品图案设计网站
  • 开彩票网站做私庄邓州市网站建设