[LeetCode]111. Minimum Depth of Binary Tree

Qualcomm Camera 启动优化实战:Preview、Snapshot、ZSL 路径控制与时延剖析 在移动终端上,Camera 的“启动速度”与“抓拍响应”是决定用户体验的关键指标。以 Qualcomm Snapdragon 平台为代表,Camera Stack 涉及 HAL 初始化、Session 配置、ISP 路径激活、Buffer 分配、图像流启动等多个异步流程,稍有设计不当将导致 Preview 启动缓慢或抓拍延迟明显。本文基于高通平台架构与 CamX 实战经验,详细剖析 Preview 与 Snapshot 启动路径,重点分析 ZSL 模式下的全链路优化策略,给出具体时延测量方法与调试参数建议。 阅读详情

[LeetCode]111. Minimum Depth of Binary Tree

题目描述

这里写图片描述

思路

深搜,如果节点为空,返回0,如果节点一个子树为空,则返回非空子树的深度

代码

#include <iostream>
#include <algorithm>
using namespace std;

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;
        }
        int leftDepth = minDepth(root->left),
            rightDepth = minDepth(root->right);
        return 1 + (min(leftDepth, rightDepth) ? min(leftDepth, rightDepth) : max(leftDepth, rightDepth));
    }
};


int main() {
    TreeNode *root = new TreeNode(1);
    TreeNode *left = new TreeNode(1);
    TreeNode *right = new TreeNode(1);
    TreeNode *child = new TreeNode(1);
    TreeNode *child2 = new TreeNode(1);

    root->left = left;
    left->left = child;
    left->right = child2;
    root->right = right;

    Solution s;

    cout << s.minDepth(root) << endl;
    system("pause");
}
HFSS实战项目——基片集成波导(SIW)带通滤波器 设计了一款直接耦合的SIW带通滤波器, 采用直接耦合的形式, 工作频率覆盖19~21 GHz, 通带内插入损耗小于1.5 dB, 回波损耗小于-20 dB, 带外抑制特性良好. 阅读详情

相关推荐

Ubuntu环境下rknn-toolkit2的安装与兼容性解析

本文详细解析了在Ubuntu系统上安装瑞芯微rknn-toolkit2工具链的完整流程与关键注意事项。文章重点剖析了rknn-toolkit2与旧版rknn-toolkit的核心兼容性问题,强调两者在API、模型格式及运行时库上互不兼容,并推荐使用Conda虚拟环境进行隔离管理,为RK3566、RK3588等开发板的AI模型部署提供清晰的实践指南。

weixin_29041767的博客 375

LeetCode 104. Maximum Depth of Binary Tree和111. Minimum Depth of Binary Tree 递归

104. Maximum Depth of Binary Tree Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.

老夫编代码就是一把梭 594

【Python・统计学】(两)多因素方差分析(原理及代码)

自学笔记,分享给对统计学原理不太清楚但需要在论文中用到的小伙伴,欢迎大佬们补充或绕道。ps:本文不涉及公式讲解(文科生小白友好体质)~(部分定义等来源于知乎) 本文重点:多因素方差分析 【1.多因素方差分析简单原理】 【2.多因素方差分析步骤】 【3.多因素方差分析代码】

TUTO_TUTO的博客 4864

LeetCode力扣 111. 二叉树的最小深度 Minimum Depth of Binary Tree 题解代码 JavaScript

问题https://leetcode-cn.com/problems/minimum-depth-of-binary-tree/ 练习使用JavaScript解答 /** * Definition for a binary tree node. * function TreeNode(val) { * this.val = val; * this.left = this.right = null; * } */ /** * @param {TreeNode} root .

Coding home - 漂流瓶jz 475

机器人运动不流畅?手把手教你用ACCSET调整ABB/FANUC点位加速度

本文针对ABB和FANUC工业机器人运动不流畅、拐角抖动、到位震颤等常见问题,提供了详细的解决方案。核心在于使用ACCSET指令(ABB)或ACC选项(FANUC)调整机器人的点位加速度与减速度参数。文章通过实战案例与系统化调试流程,手把手指导工程师优化运动性能,实现平稳、精准的机器人运动控制。

gpu4optimizer的博客 284

用AT7456E给监控摄像头加OSD?5步搞定时间水印和Logo叠加

本文详细解析了如何使用AT7456E视频字符叠加芯片为监控系统添加专业级OSD功能,涵盖硬件设计、字符库编程和系统集成等关键步骤。通过5步操作实现时间水印和Logo叠加,提升监控系统的可用性和专业性,特别适合安防和工业视觉应用。

sea99的博客 1012

LeetCode: 111. Minimum Depth of Binary Tree

LeetCode: 111. Minimum Depth of Binary Tree 题目描述 Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest...

杨领well的专栏 687

C++详解 二叉树的三种遍历方式

上一篇文章,讲了二叉树的创建——C++实现 链表存储二叉树 接下来讲解二叉树的三种遍历方式:先序(前序)遍历、中序遍历、后序遍历,三种方式都是DFS(Depth First Search)深度优先搜索,核心思想都是函数的递归(栈),如果你能理解上面这篇文章中创建二叉树的具体过程,那么遍历就轻而易举 1.先序遍历 Former_Order_Traversel(BinTree_Node* p) { ...

weixin_43335392的博客 5371

[LeetCode 111] Minimum Depth of Binary Tree

题目链接:minimum-depth-of-binary-tree /** * Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest

瓦尔登湖 1394

深入解析SPLL单相软件锁相环:从SOGI原理到PI系数调优实践

本文深入解析SPLL单相软件锁相环技术,从SOGI原理到PI系数调优实践,详细介绍了其在数字电源设计中的应用。通过数学推导和实际调试经验,帮助工程师快速掌握锁相环的核心参数计算和优化方法,提升电网相位追踪的精确度和响应速度。

weixin_30316097的博客 382

基于混合智能框架的景区边界范围预测与补全系统

摘要 本文提出一种混合智能框架,结合随机森林模型和GIS规则约束,解决景区边界缺失问题。系统基于Python和ArcGIS平台,利用多源地理空间数据训练随机森林分类器预测景区范围,并集成地形、水文、道路等GIS规则进行优化。实验结果表明,该方法能有效预测15000个景区的边界,精度优于单一模型。创新点在于: 1)数据驱动与知识驱动相结合的混合智能范式; 2)面向全国尺度的大规模边界补全; 3)提供完整的Python+ArcGIS实现方案。该系统为景区精细化管理提供了技术支撑,具有实用价值。

huanghm88的专栏 281

LeetCode 111. Minimum Depth of Binary Tree 题解

本题是二叉树的经典问题,主要考察对树的遍历和递归的理解。递归深度优先搜索:代码简洁易懂,逻辑清晰,但在树深度较大时可能会遇到栈溢出的问题。迭代广度优先搜索:在遇到第一个叶子节点时立即返回,不需要遍历整个树,对于某些情况更高效。在实际应用中,广度优先搜索通常是解决最小深度问题的首选方法,因为它可以在找到第一个叶子节点时立即返回,避免了不必要的计算。

cannonjinx的博客 4459

SAP 联产品测试

最近领导一直要求研究一下SAP联产品的使用场景,之前只是自己摸索过一次,这个重新对联产品进行一个测试。 1、首先准备好物料主数据 注意主数据中需要勾选联产品标识。 设置好物料的分摊的百分比。 2、检查BOM 在BOM中也需要维护联产品的标识 只有当组件数量未负数时,才能勾选联产品的标识。如果组件数量正值,勾选联产品的标识时会报错。 3、我们创建生产订单 可以看到按正常的生产订单下达时,系统就报错了,问题点在于离散制造的生产订单基本是结算到物料的。但是联产品是按订单结算的, 所以需要对订单类型中的结算参

我小时候很黑的博客 2110

LeetCode 力扣 111. 二叉树的最小深度 minimum depth of binary tree

大家觉得写还可以,可以点赞、收藏、关注一下吧! 也可以到我的个人博客参观一下,估计近几年都会一直更新!和我做个朋友吧!https://motongxue.cn 文章目录111. 二叉树的最小深度题目描述示例:分析代码提交结果 111. 二叉树的最小深度 题目描述 给定一个二叉树,找出其最小深度。 最小深度是从根节点到最近叶子节点的最短路径上的节点数量。 说明: 叶子节点是指没有子节点的节点。 示例: 给定二叉树 [3,9,20,null,null,15,7], 3 / \ 9 20

motongxue的博客 245

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

Leetcode 111 Minimum Depth of Binary Tree(水)

题目连接:Leetcode 111 Minimum Depth of Binary Tree解题思路:递归,每次返回子树中层数低的一个加一。/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * ...

不慌不忙、不急不躁 207

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

【LeetCode】111. Minimum Depth of Binary Tree

两种解法: (1)深度优先遍历,与maximum depth of binary tree类似,时间复杂度,递归函数栈结构空间复杂度,但需要考虑两种情况: i. 节点返回时必须为叶子节点,返回深度应该为1。 ii. 为了满足i.实现时要返回非空子树的最小深度。 (2)广度优先遍历,优势在于,深度优先遍历会遍历全部子树,这在树非常不平衡时效率比较低。可以采用广度优先遍历来克服...

weixin_42344158的博客 256

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

LeetCode之111. Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. Note:A leaf is a node with no childre...

iNiBuBian的博客 429

Leetcode【111】Minimum Depth of Binary Tree(Python版)

# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def minDepth(sel...

ssjdoudou的博客 7054

leetcode 111. Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. Note: A leaf is a ...

Weixu Liu的博客 183

Leetcode 111. Minimum Depth of Binary Tree

Leetcode 111. Minimum Depth of Binary Tree 题目: Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. Note:A leaf is a node with no children. ..

sammydai的博客 178

[leetcode 111] Minimum Depth of Binary Tree

题目要求: Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest

iam_lain的博客 460

闯关leetcode——111. Minimum Depth of Binary Tree

leetcode第111题

方亮的专栏 878

LeetCode111—Minimum Depth of Binary Tree

LeetCode111—Minimum Depth of Binary Tree

上善若水 393

LeetCode 111 Minimum Depth of Binary Tree

LeetCode 111 Minimum Depth of Binary Tree Problem Description: 给出一棵二叉树,输出二叉树中从根节点到最近叶节点所经过的节点数。 具体的题目信息: https://leetcode.com/problems/minimum-depth-of-binary-tree/description/ Example: Solut...

萤火虫啊飞呀飞 156

[LeetCode] 111. Minimum Depth of Binary Tree

原题链接: https://leetcode.com/problems/minimum-depth-of-binary-tree/ 1. 题目介绍 Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root no...

Ber03的博客 177

leetcode[111]Minimum Depth of Binary Tree

问题:给定二叉树,找其最小深度(叶子节点到根节点最短路径上的节点个数) 输入:TreeNode* root 输出:minimum_depth 思路:递归。一开始想着,只要一个儿子结点为NULL,便得到了最小深度,其实不是的,输入样例[1,2]便可证明。 看了[1]才明白自己错在哪里了,题目要求的是叶子结点到根结点最短路径,必须找到叶子结点,才可退出递归。 /** * Definiti...

Black Mamba的博客 168
上一篇: 网易2017秋招编程
下一篇: [LeetCode]100. Same Tree
charon____
博客等级 码龄11年 3粉丝 202原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值