leetcode 111. Minimum Depth of Binary Tree
来源:互联网 发布:群晖 路由器开放端口 编辑:程序博客网 时间:2024/06/03 17:57
/** * 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 dep; void dfs(TreeNode*root,int d){ if(d >= dep || root == NULL) return ; if(root->left == NULL && root->right == NULL){ dep = d; return ; } dfs(root->left,d+1); dfs(root->right,d+1); } int minDepth(TreeNode* root) { dep = 1000000000; if(root == NULL) return 0; dfs(root,1); return dep; }};
0 0
- 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
- [leetcode] 111. Minimum Depth of Binary Tree
- 111. Minimum Depth of Binary Tree LeetCode
- 【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
- 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.[Leetcode]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
- 线程安全和线程不安全理解
- hdu 2844 Coins(多重背包)
- SpringBoot之集成Redis NoSql数据库
- Context上下文的一些应用
- jsessionid
- leetcode 111. Minimum Depth of Binary Tree
- 源码分析 There is no getter for property named '*' in 'class java.lang.String
- 蓝桥杯BASIC21 sine之舞
- java.net.ConnectException: Connection refused
- 排序算法之选择排序
- JVM关闭
- 51nod 1095 Anigram单词
- Android系统中Parcelable和Serializable的区别
- 关于View 的基本原理