Skip to content

Commit 8dab545

Browse files
committed
Time: 2 ms (95.05%), Space: 82.3 MB (19.16%) - LeetHub
1 parent f6021b2 commit 8dab545

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

LeetCode/Easy/0111-minimum-depth-of-binary-tree/0111-minimum-depth-of-binary-tree.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,14 @@ public int minDepth(TreeNode root) {
3838

3939
while(!queue.isEmpty()){
4040
int queueLen = queue.size();
41+
minDepth++;
4142

4243
while(queueLen-->0){
4344
TreeNode node = queue.poll();
4445
if(node.left==null && node.right==null) return minDepth;
4546
if(node.left!=null) queue.add(node.left);
4647
if(node.right!=null) queue.add(node.right);
47-
}
48-
49-
minDepth++;
48+
}
5049
}
5150

5251
return minDepth;

0 commit comments

Comments
 (0)