首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
二叉树的最小深度
[编程题]二叉树的最小深度
热度指数:186120
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32M,其他语言64M
算法知识视频讲解
求给定二叉树的最小深度。最小深度是指树的根
结点
到最近叶子
结点
的最短路径上
结点
的数量。
示例1
输入
{1,2,3,4,5}
输出
2
说明:本题目包含复杂数据结构TreeNode,
点此查看相关信息
马上挑战
算法知识视频讲解
提交运行
算法知识视频讲解
添加笔记
求解答(399)
邀请回答
收藏(1581)
分享
提交结果有问题?
0个回答
31篇题解
添加回答
这道题你会答吗?花几分钟告诉大家答案吧!
提交观点
问题信息
树
难度:
0条回答
1581收藏
70267浏览
热门推荐
通过挑战的用户
查看代码
暴风陨石坠
2023-03-14 16:35:56
爱吃甜食的靓仔
2023-03-06 10:12:50
牛客38959...
2023-02-16 19:57:33
开心的孤勇者在抱佛脚
2023-02-14 17:38:07
Bug制造机27
2023-02-09 16:59:32
相关试题
字符串最后一个单词的长度
字符串
评论
(3594)
来自
2016乐视暑期实习生招...
字符串分隔
字符串
评论
(3164)
1993-2003年某国国内生产总...
资料分析
言语理解与表达
资料分析
评论
(1)
网易云音乐推荐(网易校招笔试真题)
网易
算法工程师
数据分析师
SQL
2021
评论
(484)
简单描述一下TCP滑动窗口机制
计算机网络体系
评论
(1)
二叉树的最小深度
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题
import java.util.*; /* * public class TreeNode { * int val = 0; * TreeNode left = null; * TreeNode right = null; * } */ public class Solution { /** * * @param root TreeNode类 * @return int整型 */ public int run (TreeNode root) { // write code here } }
/** * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ class Solution { public: /** * * @param root TreeNode类 * @return int整型 */ int run(TreeNode* root) { // write code here } };
# class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None # # # @param root TreeNode类 # @return int整型 # class Solution: def run(self , root ): # write code here
/* * function TreeNode(x) { * this.val = x; * this.left = null; * this.right = null; * } */ /** * * @param root TreeNode类 * @return int整型 */ function run( root ) { // write code here } module.exports = { run : run };
# class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None # # # @param root TreeNode类 # @return int整型 # class Solution: def run(self , root ): # write code here
package main import . "nc_tools" /* * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */ /** * * @param root TreeNode类 * @return int整型 */ func run( root *TreeNode ) int { // write code here }
{1,2,3,4,5}
2