[Leetcode]Maximum Depth of Binary Tree
来源:互联网 发布:里程碑时间轴js 编辑:程序博客网 时间:2024/05/16 19:04
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. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */int maxDepth(struct TreeNode* root) { int u = 0, v = 0; if (root == NULL){ return 0; } u = maxDepth(root->left); v = maxDepth(root->right); return (u > v ? (u+1) : (v+1));}
0 0
- Leetcode - Tree - Maximum Depth of Binary Tree
- [leetcode][tree] Maximum Depth of Binary Tree
- LeetCode Maximum Depth of Binary Tree
- [Leetcode] Maximum Depth of Binary Tree
- leetcode 24: Maximum Depth of Binary Tree
- [LeetCode] Maximum Depth of Binary Tree
- Leetcode 104 Maximum Depth of Binary Tree
- 【leetcode】Maximum Depth of Binary Tree
- [leetcode]Maximum Depth of Binary Tree
- [LeetCode]Maximum Depth of Binary Tree
- [leetcode]Maximum Depth of Binary Tree
- Leetcode: Maximum Depth of Binary Tree
- LeetCode-Maximum Depth of Binary Tree
- [leetcode] Maximum Depth of Binary Tree
- LeetCode - Maximum Depth of Binary Tree
- LeetCode:Maximum Depth of Binary Tree
- LeetCode | Maximum Depth of Binary Tree
- 【leetcode】Maximum Depth of Binary Tree
- 新浪微博分享接口|利用jiathis自定义接口
- ext4 学习笔记(十二)[样式操作系方法](白鹤翔第一季)
- 97条架构建议-大厦-混合开发-性能
- 操作系统中存储器管理及CPU对存储器的访问
- 设计模式之——简单工厂模式
- [Leetcode]Maximum Depth of Binary Tree
- Debian系统不能挂载exFAT类型格式化后的USB设备
- Gulp 自动化你的前端
- linux 下Qt初级教程(一)实现简易的计算器
- thinkphp5使用monolog
- var A={};
- 相见恨晚:linux下的c++filt 命令
- spring在service层获取session和request
- 查看集群中hive的版本