publicclass二叉树的最大深度 {/*** Definition of TreeNode:*/publicclassTreeNode {publicintval;publicTreeNode left, right;publicTreeNode(intval) {this.val =val;this.left =this.right =null; } }/***@paramroot: The root of binary tree. *@return: An integer.*/publicintmaxDepth(TreeNode ro...
[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 2019-12-11 17:53 − # ...
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-695. Max Area of Island intmaxAreaOfIsland(vector<vector<int>>&grid) {intmax=0;if(grid.size()==0)return0;for(intj=0;j<grid.size();j++) {for(inti=0;i<grid[0].size();i++) {if(grid[j][i]==1) { max=std::max(DF(grid,j,i),max);...
0094-Binary-Tree-Inorder-Traversal 0095-Unique-Binary-Search-Trees-II 0096-Unique-Binary-Search-Trees 0098-Validate-Binary-Search-Tree 0099-Recover-Binary-Search-Tree 0100-Same-Tree 0101-Symmetric-Tree 0102-Binary-Tree-Level-Order-Traversal 0104-Maximum-Depth-of-Binary-Tree...
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); ...
0104-Maximum-Depth-of-Binary-Tree 0105-Construct-Binary-Tree-from-Preorder-and-Inorder Traversal 0106-Construct-Binary-Tree-from-Inorder-and-Postorder Traversal 0107-Binary-Tree-Level-Order-Traversal-II 0108-Convert-Sorted-Array-to-Binary-Search-Tree 0109-Convert-Sorted-L...
[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 ...
每日一题# Copy https://github.com/WindrunnerMax/EveryDay 参考# Copy https://leetcode-cn.com/problems/minimum-depth-of-binary-tree/