【LeetCode】104. Maximum Depth of Binary Tree
来源:互联网 发布:易语言数据库 编辑:程序博客网 时间:2024/06/03 20:42
求二叉树的最大高度
1. 空树最大深度是0. 2. max(左子树的最大深度, 右子树最大深度) + 1
// 104. Maximum Depth of Binary Tree// 1. 空树最大深度是0. 2. max(左子树的最大深度, 右子树最大深度) + 1int solution::maxDepth(TreeNode* root){if (root == NULL) return 0;int leftDepth = maxDepth(root->left);int rightDepth = maxDepth(root->right);return leftDepth > rightDepth ? leftDepth + 1 : rightDepth + 1;}
阅读全文
0 0
- [LeetCode]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
- LeetCode 104. Maximum Depth of Binary Tree
- leetCode 104. Maximum Depth of Binary Tree
- 104. Maximum Depth of Binary Tree LeetCode
- 104. Maximum Depth of Binary Tree LeetCode
- LeetCode 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
- leetcode 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
- Leetcode 104. Maximum Depth of Binary Tree
- LeetCode *** 104. Maximum Depth of Binary Tree
- 算法学习记录八(C++)--->一句代码搞定变态跳台阶
- squirrel hbase Phonenix 三者集成
- Centos安装Erlang/OTP
- 12.using namespace std;
- C/C++内存管理
- 【LeetCode】104. Maximum Depth of Binary Tree
- Android Studio一切配置完毕卡死,进不去
- Mysql中经常用来存储日期的格式
- eclipse 的svn插件地址
- 12.重载函数
- 初涉vue
- C/S和B/S结构
- LightOJ 1048 Conquering Keokradong(二分+贪心)
- Windows 更新错误 0x80073712