LeetCode 二叉树 | 104. Maximum Depth of Binary Tree
来源:互联网 发布:做淘宝 编辑:程序博客网 时间:2024/06/05 23:40
/* * Leetcode104. Maximum Depth of Binary Tree * Funtion: Given a binary tree, find its maximum depth. * Author: LKJ * Date:2016/7/19*/#include <iostream>//#include <vector>using namespace std;struct TreeNode { int val; TreeNode* left; TreeNode* right; TreeNode(int x): val(x), left(NULL),right(NULL) {}};class Solution {public: int maxDepth(TreeNode* root) {//采用DFS的思想 if (NULL == root) return 0; int leftdepth = maxDepth(root->left); int rightdepth = maxDepth(root->right); return leftdepth > rightdepth ? leftdepth + 1 : rightdepth + 1; }};int main(){ //int myin; //int myout; //Solution SA; //cout << "Please Enter" << endl; //cin >> myin; //myout = SA.singleNumber(myin); //cout << myout << endl; //cout << getFristBit(1) << endl; return 0;}
0 0
- 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 - Tree - 104. Maximum Depth of Binary Tree(DFS求二叉树最深深度)
- [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
- caffe Ubuntu16安装 以及MNIST测试 pycaffe
- linux后台运行和关闭、查看后台任务
- 使用bootstrap实现左侧伸缩菜单
- Apple Development
- uva725 除法 暴力
- LeetCode 二叉树 | 104. Maximum Depth of Binary Tree
- query must begin with SELECT or FROM: delete
- MyEclipse2016 live preview功能引发的问题
- jQuery学习篇(6)_jQuery 滑动
- js的几种加载方式
- 排序/查找算法Java
- SBT I 入门
- Android事件分发机制详解
- 实现 SOA 安全的简单方法