1、minimum-depth-of-binary-tree
题目描述
int run(TreeNode *root){
if (root == nullptr) return ;
if (root->left == nullptr)
{
return run(root->right) + ;
}
if (root->right == nullptr)
{
return run(root->left) + ;
}
int leftDepth = run(root->left);
int rightDepth = run(root->right);
return (leftDepth <= rightDepth) ? (leftDepth + ) : (rightDepth + );
}
1、minimum-depth-of-binary-tree的更多相关文章
- leetcode -day17 Path Sum I II & Flatten Binary Tree to Linked List & Minimum Depth of Binary Tree
1. Path Sum Given a binary tree and a sum, determine if the tree has a root-to-leaf path such tha ...
- [Leetcode][JAVA] Minimum Depth of Binary Tree && Balanced Binary Tree && Maximum Depth of Binary Tree
Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum depth is the n ...
- LeetCode:Minimum Depth of Binary Tree,Maximum Depth of Binary Tree
LeetCode:Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum depth ...
- 33. Minimum Depth of Binary Tree && Balanced Binary Tree && Maximum Depth of Binary Tree
Minimum Depth of Binary Tree OJ: https://oj.leetcode.com/problems/minimum-depth-of-binary-tree/ Give ...
- 【LeetCode练习题】Minimum Depth of Binary Tree
Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum depth is the n ...
- 【LeetCode】Minimum Depth of Binary Tree 二叉树的最小深度 java
[LeetCode]Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum dept ...
- LeetCode My Solution: Minimum Depth of Binary Tree
Minimum Depth of Binary Tree Total Accepted: 24760 Total Submissions: 83665My Submissions Given a bi ...
- [LeetCode] 111. Minimum Depth of Binary Tree ☆(二叉树的最小深度)
[Leetcode] Maximum and Minimum Depth of Binary Tree 二叉树的最小最大深度 (最小有3种解法) 描述 解析 递归深度优先搜索 当求最大深度时,我们只要 ...
- LeetCode: Minimum Depth of Binary Tree 解题报告
Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum depth is the n ...
- 【LeetCode】111. Minimum Depth of Binary Tree (2 solutions)
Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum depth is the n ...
随机推荐
- iOS分类底层实现原理小记
摘要:iOS分类底层是怎么实现的?本文将分如下四个模块进行探究分类的结构体编译时的分类分类的加载总结本文使用的runtime源码版本是objc4-680文中类与分类代码如下//类@interfaceP ...
- Vue-- 监听路由变化,数据无法更新?
之前写的Vue项目,有个问题困扰了好久.新闻板块有推荐.精华.最新等几个Tab,设想通过切换Tab,改变路由参数(get/news/:tab)去获取对应数据,然后渲染到页面(用的是同一套组件),问题来 ...
- 跟随我在oracle学习php(1)
所有的web页面都由HTML(超文本标记语言)构成,每种浏览器都将代码转换成我们所看到的页面. 这是基本上是每个程序员写的第一个代码“hello world” 这是浏览器翻译后的结果 首先<&g ...
- Spring Boot + Jpa + Thymeleaf 增删改查示例
快速上手 配置文件 pom 包配置 pom 包里面添加 Jpa 和 Thymeleaf 的相关包引用 <dependency> <groupId>org.springframe ...
- C语言打印杨辉三角(2种方法)
杨辉三角是我们从初中就知道的,现在,让我们用C语言将它在计算机上显示出来. 在初中,我们就知道,杨辉三角的两个腰边的数都是1,其它位置的数都是上顶上两个数之和.这就是我们用C语言写杨辉三角的关键之一. ...
- secondPage
写的第二个页面,参照着别人的代码,网上找寻自己需要的标签,每个小地方都得试许多次才能明白标签的正确使用方法,自己动手写出来一个页面虽然超级粗糙,但是挺有收获的. <!DOCTYPE html&g ...
- design
type Config struct { Item lock } func (*Config) getItem(){ } func (*Config) SetItem(){ } channel : - ...
- 编译QFileSystemModel
QT在windows系统下可以直接安装,但有些时候,可以只编译一个类,这里需要有一些需要注意的.下面是github路径:https://github.com/1171597779/compile_of ...
- java面向对象编程(一)-类与对象
1.问题的提出 张老太养了两只猫猫:一只名字叫小白,今年3岁,白色.还有一只叫小花,今年100岁,花色.请编写一个程序,当用户输入小猫的名字时,就显示该猫的名字,年龄,颜色.如果用户输入的小 ...
- logback-spring.xml 博客分享
https://juejin.im/post/5b51f85c5188251af91a7525