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...
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] 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 294 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 294 css fonts in depth & font-variation-settings ...
package leetcode // 解法一 优化版 func maxOperations(nums []int, k int) int { counter, res := make(map[int]int), 0 for _, n := range nums { counter[n]++ } if (k & 1) == 0 { res += counter[k>>1] >> 1 // 能够由 2 个相同的数构成 k 的组合已经都排除出去了,剩下...
Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Note: The input array will only contain 0 and 1. The length
Problem: Get maximum binary Gap. For example, 9’s binary form is 1001, the gap is 2. Java Solution 1 An integer x & 1 will get the last digit of the integer. publicstaticintgetGap(intN){intmax=0;intcount=-1;intr=0;while(N>0){// get right most bit & shift rightr=N&1;N...
Perfect Binary Tree: a binary tree in which all interior nodes have two children and all leave have the same depth Complete Tree: a binary tree in which every level except possibly the last is full and all nodes in the last level are as far left as possibleBinary...
[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 294 css fonts in depth & font-variation-settings 2019-12-11 17:53 − # ...
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. The maximum number of consecutive 1s is 3. ...