Skip to content

Commit 01c2136

Browse files
committed
Time: N/A (0%), Space: N/A (0%) - LeetHub
1 parent 99f8eb4 commit 01c2136

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,13 @@ class Solution {
2020
int minDepth=0;
2121

2222
public int minDepth(TreeNode root) {
23-
if(root == null) return minDepth;
23+
if(root == null) return 0;
2424
//dfs
25-
// if(root.left==null&&root.right==null) return minDepth;
26-
if(root.left==null && root.right==null) return 1+minDepth;
25+
if(root.left==null && root.right==null) return 1;
2726
else if(root.left==null) return 1+minDepth(root.right);
2827
else if(root.right==null) return 1+minDepth(root.left);
2928
else return 1+Math.min(minDepth(root.left), minDepth(root.right));
3029

31-
// minDepth = 1+Math.min(minDepth(root.left), minDepth(root.right));
32-
33-
// return minDepth;
3430
// //bfs
3531
// if(root == null) return 0;
3632

0 commit comments

Comments
 (0)