题目描述

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.
 
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. linux下redis的安装与部署及基础命令
  2. 特殊字符导致用正则表达式进行字符串替换失败,Java replaceAll()方法报错Illegal group reference
  3. 使用mysql数据库,插入数据出现问号(?)的问题,解决方法
  4. IntelliJ IDEA 开发前的设置
  5. oracle表空间建立与用户创建删除
  6. js上传图片及预览功能
  7. Nginx Location配置总结及基础最佳实践
  8. linux下添加PATH环境变量
  9. System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(string, string)已过时的解决办法
  10. ecshop下启用QQ在线服务,并能实时更新QQ在线状态
  11. 图像转置的SSE优化(支持8位、24位、32位),提速4-6倍。
  12. JDBC在springMvc等框架中使用的方式
  13. Manifest文件的最新理解
  14. CentOS 7 系统基础配置
  15. 定位现网环境中最耗费CPU的Java线程
  16. C# 中Web.config文件的读取与写入
  17. 【noip 2012】提高组Day2T3.疫情控制
  18. 蓝牙协议分析(11)_BLE安全机制之SM
  19. 100-days: sixteen
  20. Matlab-11:Gausssidel迭代法工具箱

热门文章

  1. 字节顺序标记——BOM,Byte Order Mark
  2. 高并发情况下Linux系统及kernel参数优化
  3. 【Git】【1】简单介绍
  4. hbuider配置初始
  5. CF 3-6 2级组 D题 STRESSFUL TRAINING 紧张的比赛
  6. [hdu P4114] Disney&#39;s FastPass
  7. javascript 位操作符
  8. JQ 关于each() 箭头函数报错的问题
  9. 【Cocos2d-html5】运动中速度效果
  10. sql整体优化的五种工具