Maximum Depth of Binary Tree
来源:互联网 发布:nginx需要密码访问 编辑:程序博客网 时间:2024/06/06 07:20
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. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solution { public int maxDepth(TreeNode root) { int deep=0; if(root!=null){ int lchilddeep=maxDepth(root.left); int rchilddeep=maxDepth(root.right); deep=lchilddeep>rchilddeep?lchilddeep+1:rchilddeep+1; } return deep; }}
0 0
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- Maximum Depth of Binary Tree
- C语言位运算符:与、或、异或、取反、左移和右移
- 使用Intent实现活动间的跳转和数据传递
- 枚举的作用
- lucene_indexWriter说明、索引库优化
- 通过AndroidTestCase来进行android 单元测试 part I
- Maximum Depth of Binary Tree
- android基本架构
- 感悟:Java的多线程跟Java的类系统之间的关系
- 01背包问题
- java 多线程--概要
- 每天laravel-20160620|MemcachedConnector
- 码农小汪-剑指Offer之12 -链表中倒数第k个结点
- python学习的一些小技巧小结
- C# 全局变量与局部变量