每一步向前都是向自己的梦想更近一步,坚持不懈,勇往直前! 第一题:111. 二叉树的最小深度 - 力扣(LeetCode) /*** Definition for a binary tree node.* public class TreeNode {* int val;* TreeNode left;* TreeNode right;* TreeNode(
题目: 题解: class Solution:def minDepth(self, root: TreeNode) -> int:if not root:return 0que = collections.deque([(root, 1)])while que:node, depth = que.popleft()if not node.left and not node.right:re
配置thinkphp环境时报错 Parse error: syntax error, unexpected T_CONST in /www/web/111_com/public_html/youxicidian/ThinkPHP/ThinkPHP.php on line 23 appserv用的是2.5.10版本 thinkphp用的是3.2版本 解决方法一:将thinkp
链接:http://acm.njupt.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=1079 题目: 111… Time Limit(Common/Java):1000MS/3000MS Memory Limit:65536KByte Total Submit:301 Accepte
题目链接:https://leetcode.com/problems/minimum-depth-of-binary-tree/ 求树的最小深度,也就是说:沿着树的路径从根节点到最近叶节点的距离。 需要一个队列进行层次遍历(BFS,对层次进行计数),在某一层找到叶节点时返回。 class Solution {public static int minDepth(TreeNode root)