104. Maximum Depth of Binary Tree(菜鸟刷题第一天)
来源:互联网 发布:大数据电商平台 编辑:程序博客网 时间:2024/06/07 05:50
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.
Subscribe to see which companies asked this question
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution {public: int max(int a,int b) { if(a>b) return a; else return b; } int maxDepth(TreeNode* root) { if(root==NULL) return 0; else return max(maxDepth(root->left),maxDepth(root->right))+1; } };
0 0
- 104. Maximum Depth of Binary Tree(菜鸟刷题第一天)
- 【一天一道LeetCode】#104. Maximum Depth of Binary Tree
- leecode: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] 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
- 104. Maximum Depth of Binary Tree
- 104.Maximum Depth of Binary Tree
- 104. Maximum Depth of Binary Tree
- 104. Maximum Depth of Binary Tree
- leetCode 104. Maximum Depth of Binary Tree
- 104. Maximum Depth of Binary Tree
- 104. Maximum Depth of Binary Tree LeetCode
- 104. Maximum Depth of Binary Tree LeetCode
- leetcode第3题——**Longest Substring Without Repeating Characters
- 字符串的全排列算法讲解
- Keytool工具使用方法
- 张氏读写锁,c++信号量实现
- C++ bitset的使用简介
- 104. Maximum Depth of Binary Tree(菜鸟刷题第一天)
- linux编译驱动之 make modules SUBDIRS
- C++:顺序容器及顺序容器适配器(stack、queue、priority_queue)
- Mysql备份和恢复
- Spark Shuffle内存分析
- delphi(客户端) socket 与 PHP_socket(服务器) 通信的例子
- dz论坛程序备份搬家
- 常用oracle函数备份
- 动态创建mfc控件