Maximum Depth of Binary Tree
来源:互联网 发布:九芝堂 知乎 编辑:程序博客网 时间:2024/04/29 03:30
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.
比较简单,用dfs就行。
int maxDepth(TreeNode *root) { if (root == NULL) return 0; int lDepth = maxDepth(root->left); int rDepth = maxDepth(root->right); return max(lDepth, rDepth) + 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
- Matlab函数kmeans
- Android如何防止apk程序被反编译
- 闭包
- iOS手势识别的详细使用(拖动,缩放,旋转,点击,手势依赖,自定义手势)
- unity导出obj格式
- Maximum Depth of Binary Tree
- 解决 :RHEL5 同时配置 EPEL RPMForge 软件源时,安装 VLC 报错
- gdb混合c和nasm调试记录
- asp.net开发webservice 入门问题总结
- (20)基础加强-内省-注解
- 复习iOS证书申请和生成过程
- Freemarker相关
- 8.HTML5 CSS3 背景、边框与补丁相关属性
- Clojure教程-基本语法