Maximum Depth of Binary Tree
来源:互联网 发布:国产视频制作软件 编辑:程序博客网 时间:2024/06/07 22:04
Maximum Depth of Binary Tree
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; } * } */class Solution { public int maxDepth(TreeNode root) { if (root == null) { return 0; } int left = maxDepth(root.left); int right = maxDepth(root.right); return Math.max(left, right) + 1; }}
阅读全文
0 0
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- C++ 图论-拓扑排序
- Namenode HA原理详解
- C++ --- 引用
- openjudge 区间合并(贪心)
- 优先级接触生效(两运算符和变量直接相邻)
- Maximum Depth of Binary Tree
- golang实现图片颜色反转、图片灰度、转为字符画
- python字符串与文件的操作
- dijkstra算法入门
- java的初始化块、静态初始化块、构造函数的执行顺序
- 51nod 1416
- 【Zigbee技术入门教程-02】一图读懂ZStack协议栈的基本架构和工作机理
- codeforces 848B
- 总线基础--SPI总线