leetcode #100 Maximum Depth of Binary Tree
来源:互联网 发布:淘宝降权后多久恢复 编辑:程序博客网 时间:2024/06/10 01:02
递归实现:
/** * 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) { if(root==null)return 0; if(root.left==null&&root.right==null)return 1; return Math.max(1+maxDepth(root.left),1+maxDepth(root.right)); }}
Fight On!
0 0
- leetcode #100 Maximum Depth of Binary Tree
- 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
- iOS-- Nsstirng,Nsdata,char,byte,UIImage 之间的转换
- 10、Java集合
- Linux命令简介—more
- bloomfilter的实现
- 八大排序算法的Python实现
- leetcode #100 Maximum Depth of Binary Tree
- 类加载器
- cocos2d-x lua调用c++函数
- asp生成xml文件
- RequireJS入门(一)
- Java基础——对象和类,类中的变量和方法
- UVA 11552 Fewest Flops
- Mac下eclipse环境配置问题集锦
- PopupWindow弹出时底层变暗(像Dialog弹出时的效果)