[C]LeetCode:Maximum Depth of Binary Tree
来源:互联网 发布:intent传递int数据 编辑:程序博客网 时间:2024/06/06 06:59
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算法
/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */int maxDepth(struct TreeNode* root) { if (root==NULL) return 0; int suml=maxDepth(root->left); int sumr=maxDepth(root->right); return suml>sumr?suml+1:sumr+1;}
0 0
- [C]LeetCode:Maximum Depth of Binary Tree
- Leetcode - Tree - Maximum Depth of Binary Tree
- [leetcode][tree] Maximum Depth of Binary Tree
- [C++]LeetCode: 29 Maximum Depth of Binary Tree
- 【leetcode c++】104 Maximum Depth of Binary Tree
- [leetcode-104]Maximum Depth of Binary Tree(c)
- LeetCode 104. Maximum Depth of Binary Tree C语言
- Leetcode-104. Maximum Depth of Binary Tree c语言
- LeetCode 104. Maximum Depth of Binary Tree 题解(C++)
- LeetCode 104. Maximum Depth of Binary Tree (C++)
- [LeetCode] [C] 104. 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
- poj 2142 The Balance(扩展欧几里德算法)
- 228. Summary Ranges
- 629A.Far Relative’s Birthday Cake
- C++ 按指定分隔符拆分字符串
- 56-题目1087:约数的个数
- [C]LeetCode:Maximum Depth of Binary Tree
- 慕课网Zepto.js课程学习笔记
- 常用网络管理操作
- Java网络编程——InetAddress
- 寻找 tableview 中的最后一行|自动滚动到最后一行
- 【高性能】linux加载当前目录的动态库
- 【数据结构】线性表(链表实现)
- 正则表达式的学习(二)
- 产品经理的自我管理能力 之 目标管理、知识管理-----产品经理深入浅出课程