111. Minimum Depth of Binary Tree
来源:互联网 发布:mac修改mysql配置文件 编辑:程序博客网 时间:2024/06/16 22:11
用DFS完成
int minDepth(TreeNode* root) { if(!root) return 0; if(!root->left&&!root->right) return 1; if(root->left==NULL) return 1+minDepth(root->right); else if(root->right==NULL) return 1+minDepth(root->left); else return 1+min(minDepth(root->left),minDepth(root->right)); }
阅读全文
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
- 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
- 111. Minimum Depth of Binary Tree
- 类似于陌陌点点和探探首页切换效果
- 图像处理笔试面试题(1)
- 第八周 【项目2
- 第三周 项目1
- qt5.8 中文乱码
- 111. Minimum Depth of Binary Tree
- template.js
- STM32串口打印printf发送中文乱码问题
- Java 中的两种查找算法方式
- 简单数谜 (caioj1044)
- DateTimePicker控件CustomFormat格式字符串及其说明
- tabLayout改变下划线的宽度
- python 解决数组赋值问题
- 第15周项目2