LeetCode 104. Maximum Depth of Binary Tree
来源:互联网 发布:淘宝商家商品折扣 编辑:程序博客网 时间:2024/05/22 12:14
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 == NULL) return 0; int len1 = maxDepth(root->left); int len2 = maxDepth(root->right); return len1 > len2?len1 + 1: len2 + 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
- leetcode357. Count Numbers with Unique Digits
- mysql半一致性读案例分析
- Java中实现MongoDB的Group功能
- Exchange 2010 PS 之Set-CASMailbox!
- 【Python学习笔记】python高级特性:迭代器
- LeetCode 104. Maximum Depth of Binary Tree
- Andrew NG 《machine learning》week 6,class2—Bias vs. Variance
- Storm概念、原理详解及其应用(一)BaseStorm
- TextView源码解析-----绘制过程
- [Android]自定义多选AutoComplete收信人控件
- 内存屏障
- Java-内省(Introspector)
- [JAVA]简单定义和使用内部类
- 易语言用户葛大强