leetcode(1)
来源:互联网 发布:wps表格查找重复数据 编辑:程序博客网 时间:2024/04/29 06:08
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.
public class Solution { public int run(TreeNode root) { return getDepth(root,0); } public static int getDepth(TreeNode node,int height){ if(node==null){ return height; } if(node.left==null){ return getDepth(node.right,height+1); } if(node.right==null){ return getDepth(node.left,height+1); } return Math.min(getDepth(node.left,height+1),getDepth(node.right,height+1)); }}
阅读全文
0 0
- Leetcode 1
- leetcode(1)
- leetcode 1
- leetcode 1
- leetcode-1
- leetcode 1
- LeetCode(1)
- leetcode 1
- LeetCode(1)
- LeetCode 1
- leetcode-1
- leetcode(1)
- leetcode-1
- LeetCode (1)
- leetcode-1
- leetcode 1
- leetcode(1)
- leetcode 1
- highcharts报表 三:plotOptions 针对所有图表有效的通用配置
- 第十四周:( LeetCode593) Valid Square(c++)
- 服务器端 I/O 性能:Node vs. PHP vs. Java vs. Go
- 转-【CTF环境搭建之】如何使用Android反编译软件
- java单例模式学习
- leetcode(1)
- Linux CentOS 7安装GNOME图形界面并设置默认启动方式
- Maven技术小结
- vim常用命令总结(转)
- DiskLruCache磁盘缓存
- es6中Map结构相关
- cips2016-中文信息处理发展阅读笔记
- MATLAB面向对象编程中类的默认优先级
- 勒索病毒工作原理