2017.11.5 LeetCode
来源:互联网 发布:全聚合电视直播软件 编辑:程序博客网 时间:2024/06/02 21:08
104. Maximum Depth of Binary Tree
Description
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.
题意: 求一颗二叉树的深度
分析: 直接dfs模拟即可
参考函数
class Solution {public: int res = 0; void dfs(TreeNode* root,int c) { if(!root) return ; res = max(res,c); dfs(root->left,c+1); dfs(root->right,c+1); } int maxDepth(TreeNode* root) { dfs(root,1); return res; }};
阅读全文
0 0
- 2017.11.5 LeetCode
- LeetCode--5
- Leetcode 5
- LeetCode(5)
- LeetCode(5)
- LeetCode(5)
- 2017.11.1 LeetCode
- 2017.11.2 LeetCode
- 2017.11.3 LeetCode
- 2017.11.4 LeetCode
- 2017.11.9 LeetCode
- 2017.11.14 LeetCode
- 2017.11.21 LeetCode
- 2017.11.22 LeetCode
- Leetcode (5) Same Tree
- Leetcode Freq 4,5
- leetCode(5):Sort List
- Leetcode--easy系列5
- Android Studio获取开发版SHA1值和发布版SHA1值的史上最详细方法
- 单源最短路(bellmanford&spfa)
- HDOJ 1266 Reverse Number
- multiple definition of XXX
- POJ 1789
- 2017.11.5 LeetCode
- 自定义View之Paint
- 容易遗忘的东西(持续添加中)
- Ajax学习笔记
- 面向对象和基于对象的区别
- android 支付宝支付 出现"系统繁忙,请稍后重试(ALI10)"
- 基于cnn的情感分类
- “安全性与隐私”中没有“任何来源”选项
- API接口测试用例设计