leetcode_题解_Maximum Depth of Binary Tree_简单题
来源:互联网 发布:app建站 编辑:程序博客网 时间:2024/05/18 00:51
递归函数调用DFS(没有用显式栈,居然AC了)
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Solution {public: int maxDepth(TreeNode *root) { if(!root) return 0; else if(root->left==NULL && root->right==NULL) return 1; else { int ldeep,rdeep; ldeep=maxDepth(root->left); rdeep=maxDepth(root->right); if(ldeep>rdeep) return ldeep+1; else return rdeep+1; } }};
0 0
- leetcode_题解_Maximum Depth of Binary Tree_简单题
- leetcode_题解_Minimum Depth of Binary Tree _easy需细心
- leetcode第一刷_Maximum Depth of Binary Tree
- leetcode_104._Maximum Depth of Binary Tree(C++)(easy)
- LeetCode:104_Maximum Depth of Binary Tree | 二叉树的最大深度 | Easy
- LeetCode题解:Maximum Depth of Binary Tree
- LeetCode题解:Minimum Depth of Binary Tree
- LeetCode题解:Minimum Depth of Binary Tree
- LeetCode题解:Maximum Depth of Binary Tree
- LeetCode题解:Maximum Depth of Binary Tree
- LeetCode:104_Maximum Depth of Binary Tree | 二叉树的最大深度 | 深度优先与广度优先深入理解
- leetcode_题解_Merge Sorted Array _简单题
- LeetCode 题解(12):Maximum Depth of Binary Tree
- 【LeetCode】【Python题解】Single Number & Maximum Depth of Binary Tree
- leetcode Minimum Depth of Binary Tree C++题解
- LeetCode 题解(220) : Minimum Depth of Binary Tree
- [81][E][leetcode 题解]Minimum Depth of Binary Tree
- Leetcode题解 104. Maximum Depth of Binary Tree
- 怎么获得pb数据窗口中的所有列的名字,包括不显示的列
- html/jsp有些别的电脑不可以显示
- HTML:介绍几个不常用的HTML标签
- 如何用CSS控制图片自适应大小的方法
- python os.path.sep
- leetcode_题解_Maximum Depth of Binary Tree_简单题
- UITextField键盘点击实现登录效果
- C++2005调用C#Webservice接口返回值为List
- oracle-12514错误
- 使用swingbench实现oracle数据库压力测试
- Android 4.0.3 CTS 测试
- 为什么Lisp语言如此先进?
- 操作数组
- 详细介绍一下Anchor标记