return max(maxDepth(root->left),maxDepth(root->right)) + 1; } }; 二、最小深度问题 最小深度是沿着从根节点到最近叶节点的最短路径的节点数量 描述: Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to...
https://leetcode-cn.com/problems/minimum-depth-of-binary-tree/
0557-Reverse-Words-in-a-String-III 0559-Maximum-Depth-of-N-ary-Tree 0561-Array-Partition-I 0563-Binary-Tree-Tilt 0572-Subtree-of-Another-Tree 0583-Delete-Operation-for-Two-Strings 0589-N-ary-Tree-Preorder-Traversal 0590-N-ary-Tree-Postorder-Transversal 0598-Range-Ad...
[Leetcode] 104. Maximum Depth of Binary Tree 2019-12-08 11:38 − 1 int depth = 0; 2 int currentMaxDepth = 0; 3 public int maxDepth(TreeNode root) { 4 if(root == null){ 5 ret... seako 0 295 case when语法 2019-12-23 14:04 − Case具有两种格式。简单Case函数和Case...
[Leetcode] 104. Maximum Depth of Binary Tree 2019-12-08 11:38 −1 int depth = 0; 2 int currentMaxDepth = 0; 3 public int maxDepth(TreeNode root) { 4 if(root == null){ 5 ret... seako 0 295 css fonts in depth & font-variation-settings ...
Go packageleetcode// 解法一 优化版funcmaxOperations(nums[]int,kint)int{counter,res:=make(map[int]int),0for_,n:=rangenums{counter[n]++}if(k&1)==0{res+=counter[k>>1]>>1// 能够由 2 个相同的数构成 k 的组合已经都排除出去了,剩下的一个单独的也不能组成 k 了// 所以这里要把它的...
LeetCode 543. Diameter of Binary Tree public int diameterOfBinaryTree(TreeNode root) { if (root==null) return 0; return Math.max(depthTree...(root.left)+depthTree(root.right),Math.max(diameterOfBinaryTree(root.left),diameterOfBinaryTree(root.right...int left = getDiameter(root.left); ...
0557-Reverse-Words-in-a-String-III 0559-Maximum-Depth-of-N-ary-Tree 0561-Array-Partition-I 0563-Binary-Tree-Tilt 0572-Subtree-of-Another-Tree 0583-Delete-Operation-for-Two-Strings 0589-N-ary-Tree-Preorder-Traversal 0590-N-ary-Tree-Postorder-Transversal 0598-Range-...
[Leetcode] 104. Maximum Depth of Binary Tree 2019-12-08 11:38 − 1 int depth = 0; 2 int currentMaxDepth = 0; 3 public int maxDepth(TreeNode root) { 4 if(root == null){ 5 ret... seako 0 295 css fonts in depth & font-variation-settings 2019-12-11 17:53 − # ...
8. leetcode 485. Max Consecutive Ones Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input:[1,1,0,1,1,1] Output:3 Explanation:The first two digits or the last three digits are consecutive 1s....