LeetCode 104. Maximum Depth of Binary Tree
来源:互联网 发布:担保行业 知乎 编辑:程序博客网 时间:2024/05/17 20:45
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solution { public int maxDepth(TreeNode root) { int leftDepth = 1; int rightDepth = 1; if (root == null) { return 0; } if (root.left != null) { leftDepth += maxDepth(root.left); } if (root.right != null) { rightDepth += maxDepth(root.right); } return leftDepth > rightDepth ? leftDepth : rightDepth; }}
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
- play框架使用起来(10)
- RxJava使用场景整理
- 求和 sum
- Android数据库改变监听,ContentObserver使用
- MFC六大核心机制之三:动态创建
- LeetCode 104. Maximum Depth of Binary Tree
- Scrapy ——自动多网页爬取(抓取某人博客所有文章)(四)
- C#中的字符串比较
- QT简单编程
- C++静态库与动态库
- oracle怎么查询当前用户,有多少张表
- BZOJ 3012/Luogu 3065 [Usaco2012 Dec]First!
- LeetCode 258. Add Digits
- Bootstrap3modal嵌套|模态框嵌套滚动条bug