need cut branch 111. Minimum Depth of Binary Tree
来源:互联网 发布:学java好还是c 好 编辑:程序博客网 时间:2024/05/20 23:37
/** * 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 minDepth(TreeNode* root) { if(!root) return 0; if(!root->left&&!root->right) return 1; int l=0; if(root->left) l=minDepth(root->left); int r=0; if(root->right) r=minDepth(root->right); if(!l) return r+1; if(!r) return l+1; if(l<r) return l+1; return r+1; }};
0 0
- need cut branch 111. Minimum Depth of Binary Tree
- LeetCode 111. Minimum Depth of Binary Tree
- [LeetCode]111.Minimum Depth of Binary Tree
- 【LeetCode】111.Minimum Depth of Binary Tree
- [Leetcode] 111. Minimum Depth of Binary Tree
- 111.Minimum Depth of Binary Tree
- 111. Minimum Depth of Binary Tree
- [leetcode] 111. Minimum Depth of Binary Tree
- 111. Minimum Depth of Binary Tree
- 111. Minimum Depth of Binary Tree
- 111. Minimum Depth of Binary Tree
- 111. Minimum Depth of Binary Tree LeetCode
- 111. Minimum Depth of Binary Tree
- 111. Minimum Depth of Binary Tree
- 【LeetCode】111. Minimum Depth of Binary Tree
- 111. Minimum Depth of Binary Tree
- 111. Minimum Depth of Binary Tree
- LeetCode *** 111. Minimum Depth of Binary Tree
- 2016一号特急文:三网融合的全国、全面、深入,IPTV再迎政策利好(来源:@张维才 中国网络视频产业论坛)
- MessageDigest使用过程的一个记录
- Pascal's Triangle
- ListView继续学习 长按显示菜单menu
- Ubuntu Linux 12.04 64位下Intel Math Kernel Library (MKL) 2013安装以及使用
- need cut branch 111. Minimum Depth of Binary Tree
- 美国政府实施数据中心冻结令 已关闭3300多个(来源:云头条)
- need improve 3. Longest Substring Without Repeating Characters
- 缓存之Jedis API篇
- 【2016年Esri开发者大会亮点解析】全新ArcGIS Python API,弥补Web端使用Python空白
- need improve 8. String to Integer (atoi)
- 198. House Robber
- Spring Boot系列——简介
- need improve 202. Happy Number