[Leetcode]Minimum Depth of Binary Tree
来源:互联网 发布:李嘉诚 马云 知乎 编辑:程序博客网 时间:2024/05/01 16:14
/** * 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 minDepth(TreeNode *root) { // Start typing your C/C++ solution below // DO NOT write int main() function if(root == NULL) return 0; if(!root->left) return minDepth(root->right) + 1; if(!root->right) return minDepth(root->left) + 1; return min(minDepth(root->left), minDepth(root->right)) + 1; }};
- LeetCode: Minimum Depth of Binary Tree
- [Leetcode] Minimum Depth of Binary Tree
- LeetCode : Minimum Depth of Binary Tree
- leetcode 31: Minimum Depth of Binary Tree
- [LeetCode] Minimum Depth of Binary Tree - BFS
- [LeetCode] Minimum Depth of Binary Tree - DFS
- 【leetcode】Minimum Depth of Binary Tree
- LeetCode:Minimum Depth of Binary Tree
- [LeetCode]Minimum Depth of Binary Tree
- [Leetcode]Minimum Depth of Binary Tree
- [leetcode]Minimum Depth of Binary Tree
- Leetcode: Minimum Depth of Binary Tree
- LeetCode-Minimum Depth of Binary Tree
- [leetcode] Minimum Depth of Binary Tree
- LeetCode - Minimum Depth of Binary Tree
- 【Leetcode】Minimum Depth of Binary Tree
- LeetCode | Minimum Depth of Binary Tree
- LeetCode - Minimum Depth of Binary Tree
- dojo 2
- Android Wi-Fi Display(Miracast)介绍
- Spark: Open Source Superstar Rewrites Future of Big Data
- dojo 3
- strcpy和memcpy主要有以下3方面的区别
- [Leetcode]Minimum Depth of Binary Tree
- 有理想的程序员必须知道的15件事
- 抽象一个形状类————课本P410
- 协同开发中SVN的使用规范
- 在局域网内怎样查看访问共享文件的用户
- Cocos2d-x游戏,嵌入UC sdk问题之XML配置问题
- 编辑框等控件边框美化
- 第一次使用栈
- struts2配置文件详解2