LeetCode Maximum Depth of Binary Tree
来源:互联网 发布:提高软件质量 编辑:程序博客网 时间:2024/06/06 02:00
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 binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Solution {public: int maxDepth(TreeNode *root) { if(root == NULL) return 0; else { return max(maxDepth(root->left),maxDepth(root->right))+1; } }private:int max(const int &a, const int &b) {return a > b? a : b;}};
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
- navicat for mysql只导出数据表结构
- iOS开发 mac证书无法展开
- JAVA注解
- win7下 无法创建AVD
- 112041 Rac CTSS service start failed during Gi install on AIX 7.1
- LeetCode Maximum Depth of Binary Tree
- JS学习笔记
- LCS算法讲解
- zz 矩阵分解的Jungle
- [设计模式]-建造者模式(Builder)
- 在数字时代,你的文件和记忆不再真正属于你,他们属于“云”。
- mysql创建无敌用户(ip无法远程登录)
- java项目打jar包
- SQL连接查询图展示