leetcode--104. Maximum Depth of Binary Tree
来源:互联网 发布:雍正王朝 知乎 编辑:程序博客网 时间:2024/06/06 17:50
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; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Solution {public: int maxDepth(TreeNode* root) { if(!root) return 0; return max(maxDepth(root->left), maxDepth(root->right)) + 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
- 素数之和(筛法求素数)
- [在线等]1句算简单也算困难的SQL语句高手来下
- NYOJ277 - 车牌号
- 判断复选框并写入数据库
- C语言可变参数列表解析及简单应用
- leetcode--104. Maximum Depth of Binary Tree
- 【PAT-T】1014. Circles of Friends (35)
- innerHTML的使用
- NYOJ1 - A+B Problem
- 第七章 类
- 算法之路二:刘汝佳算法竞赛入门经典:STL队列 团体队列UVA540
- RAM和ROM的区别
- 使用informix的ontape实现指定时间点的数据恢复
- 高并发下数据写入与过期