104. Maximum Depth of Binary Tree (二叉树最大深度)
来源:互联网 发布:mac打开侧边栏快捷键 编辑:程序博客网 时间:2024/05/16 02:29
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solution { public int maxDepth(TreeNode root) { if(root == null)return 0;else{ int l = maxDepth(root.left); int r = maxDepth(root.right);return l>r?l+1:r+1;} }}
0 0
- 【LeetCode】Maximum Depth of Binary Tree (二叉树最大深度)
- Maximum Depth of Binary Tree 二叉树的最大深度
- Maximum Depth of Binary Tree 二叉树的最大深度
- Leetcode Maximum Depth of Binary Tree 二叉树最大深度
- Maximum Depth of Binary Tree 二叉树的最大深度
- Maximum Depth of Binary Tree 二叉树的最大深度
- maximum-depth-of-binary-tree(二叉树的最大深度)
- 104.Maximum Depth of Binary Tree(二叉树深度)
- leetCode 104.Maximum Depth of Binary Tree(二叉树最大深度) 解题思路和方法
- Leetcode 104.Maximum Depth of Binary Tree (二叉树的最大深度)
- 104. Maximum Depth of Binary Tree (二叉树最大深度)
- 104. Maximum Depth of Binary Tree | 二叉树的深度
- 【LeetCode】104. Maximum Depth of Binary Tree 求解二叉树最大深度
- LeetCode OJ-104. Maximum Depth of Binary Tree(求二叉树最大深度)
- [LeetCode]104. Maximum Depth of Binary Tree(二叉树最大深度)
- [LeetCode]104. Maximum Depth of Binary Tree--二叉树的最大深度
- Leetcode#104. Maximum Depth of Binary Tree(最大二叉树的深度)
- Maximum Depth of Binary Tree 二叉树的最大深度(重)
- 本博客不在更新了
- Day52、单行函数、日期类型和常用的日期函数、多表查询(表连接)、内连接、外连接
- HDU 1950 POJ 1631 Bridging signals【LIS,二分优化】
- 【Day33】Apache服务器的负载平衡
- Java NIO vs. IO
- 104. Maximum Depth of Binary Tree (二叉树最大深度)
- HUE3.10本地安装
- drawText的坐标问题
- 三种方式记录bash输出的内容
- HDOJ 1874 畅通工程续(最短路)
- CF 3D Least Cost Bracket Sequence
- NOIP算法总结——关于简单 线性动态规划
- C++动态内存操作
- 107. Binary Tree Level Order Traversal II (二叉树由底向上层次遍历)