leetcode 之Maximum Depth of Binary Tree 用 C语言实现
来源:互联网 发布:mac brew install jdk 编辑:程序博客网 时间:2024/06/07 18:04
/**
* 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;
else if (root->left == NULL && root->right == NULL)
return 1;
else {
int left = maxDepth(root->left);
int right = maxDepth(root->right);
return 1 + (left > right ? left : right);
}
}
* 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;
else if (root->left == NULL && root->right == NULL)
return 1;
else {
int left = maxDepth(root->left);
int right = maxDepth(root->right);
return 1 + (left > right ? left : right);
}
}
0 0
- leetcode 之Maximum Depth of Binary Tree 用 C语言实现
- LeetCode 104. Maximum Depth of Binary Tree C语言
- Leetcode-104. Maximum Depth of Binary Tree c语言
- [C]LeetCode:Maximum Depth of Binary Tree
- LeetCode 之 Maximum Depth of Binary Tree
- LeetCode之Maximum Depth of Binary Tree
- LeetCode之Maximum Depth of Binary Tree
- leetcode 之 Maximum Depth of Binary Tree
- leetCode 之 Maximum Depth of Binary Tree
- LeetCode之Maximum Depth of Binary Tree
- leetcode之Maximum Depth of Binary Tree
- leetcode之 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 - Maximum Depth of Binary Tree
- [leetcode][tree] Maximum Depth of Binary Tree
- [C++]LeetCode: 29 Maximum Depth of Binary Tree
- Cannot merge new index 65636 into a non-jumbo instruction
- 自我练习
- sql server的存储过程
- 【小问题】js连接符,+;变量的保存。
- 有向图强连通分量 Tarjan算法【java实现】
- leetcode 之Maximum Depth of Binary Tree 用 C语言实现
- Android自定义View的实现方法,带你一步步深入了解View(四)
- 关于JVM的常见问题(一)
- Java CountDownLatch 异步转同步的实现方法
- SQL_自动生成党组织编码
- 235. Lowest Common Ancestor of a Binary Search Tree
- Cocos 资料大全 下载链接地址
- 嵌入式linux系统开发概述之六----图形用户界面(GUI)
- 腾讯力作!iOS 9 人机界面指南(5):图标与图形设计