求二叉树的最大深度 Maximum Depth of Binary Tree
来源:互联网 发布:c语言三阶幻方的判断 编辑:程序博客网 时间:2024/05/16 14:08
题目源自于Leetcode,简单递归题。时间复杂度为O(N),空间复杂度为O(logN)。
class Solution {public: int maxDepth(TreeNode *root) { if(root == NULL) return 0; else { int l = maxDepth(root->left); int r = maxDepth(root->right); return 1 + (l>r?l:r); } }};
- 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
- [leetcode]Maximum Depth of Binary Tree (求二叉树的最大深度 C语言)
- leetcode系列(28)Maximum Depth of Binary Tree 求二叉树的最大深度
- Maximum Depth of Binary Tree --- 求二叉树的最大深度
- 【LeetCode】Maximum Depth of Binary Tree (二叉树最大深度)
- Leetcode Maximum Depth of Binary Tree 二叉树最大深度
- LeetCode OJ-104. Maximum Depth of Binary Tree(求二叉树最大深度)
- Maximum Depth of Binary Tree--二叉树的深度
- 104. Maximum Depth of Binary Tree | 二叉树的深度
- Maximum Depth of Binary Tree 二叉树的最大深度(重)
- LeetCode OJ 之 Maximum Depth of Binary Tree (二叉树的最大深度)
- LinCode Maximum Depth of Binary Tree 二叉树的最大深度
- LeetCode 104 Maximum Depth of Binary Tree(二叉树的最大深度)
- kaptcha 简单方便的验证码生成工具
- 消息队列所有函数的使用
- JSP 分页框架 Pager Tag Library使用
- Collections.copy的使用
- Oracle RMAN 使用RMAN恢复ACTIVE状态的日志
- 求二叉树的最大深度 Maximum Depth of Binary Tree
- UVA 10994 Simple Addition
- java中的陷阱 你注意了么?
- python 中文乱码问题
- 对信息熵的再认识
- CSDN 赚积分方法
- php.ini extension”模块
- jBPM4.3 一个请假例子 web
- Demystifying the Linux Kernel Socket File Systems (Sockfs)